From 11b76834bc9095e50ce27235db44b34dc00b40a6 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 21 Jul 2018 16:15:54 +0200 Subject: [PATCH] refactoring --- .../{Google => Identity}/AuthToken.cs | 2 +- Yavsc.Abstract/Identity/Me.cs | 9 +++++++++ Yavsc.Server/Services/GoogleApis/PeopleApi.cs | 1 + Yavsc/ApiControllers/AccountController.cs | 2 +- test/src/YavscWorkInProgress.cs | 19 ++++++++++++------- 5 files changed, 24 insertions(+), 9 deletions(-) rename Yavsc.Abstract/{Google => Identity}/AuthToken.cs (98%) create mode 100644 Yavsc.Abstract/Identity/Me.cs diff --git a/Yavsc.Abstract/Google/AuthToken.cs b/Yavsc.Abstract/Identity/AuthToken.cs similarity index 98% rename from Yavsc.Abstract/Google/AuthToken.cs rename to Yavsc.Abstract/Identity/AuthToken.cs index 22a22d3d..2893b46d 100644 --- a/Yavsc.Abstract/Google/AuthToken.cs +++ b/Yavsc.Abstract/Identity/AuthToken.cs @@ -20,7 +20,7 @@ // along with this program. If not, see . -namespace Yavsc.Models.Google +namespace Yavsc.Abstract.Identity { /// /// Auth token, as they are received. diff --git a/Yavsc.Abstract/Identity/Me.cs b/Yavsc.Abstract/Identity/Me.cs new file mode 100644 index 00000000..1996cb9a --- /dev/null +++ b/Yavsc.Abstract/Identity/Me.cs @@ -0,0 +1,9 @@ +namespace Yavsc.Abstract.Identity { + public class Me : UserInfo + { + public AuthToken Token { + get; + set; + } + } +} diff --git a/Yavsc.Server/Services/GoogleApis/PeopleApi.cs b/Yavsc.Server/Services/GoogleApis/PeopleApi.cs index 89a31e7c..e67fa30e 100644 --- a/Yavsc.Server/Services/GoogleApis/PeopleApi.cs +++ b/Yavsc.Server/Services/GoogleApis/PeopleApi.cs @@ -22,6 +22,7 @@ using System.IO; using System.Net; using Newtonsoft.Json; +using Yavsc.Abstract.Identity; using Yavsc.Models.Google; namespace Yavsc.GoogleApis diff --git a/Yavsc/ApiControllers/AccountController.cs b/Yavsc/ApiControllers/AccountController.cs index f2b2035b..a28f495f 100644 --- a/Yavsc/ApiControllers/AccountController.cs +++ b/Yavsc/ApiControllers/AccountController.cs @@ -142,7 +142,7 @@ namespace Yavsc.WebApi.Controllers .Include(u=>u.Roles) .FirstAsync(u=>u.Id == uid); - var user = new Me(userData.Id, userData.UserName, userData.Email, + var user = new Yavsc.Models.Auth.Me(userData.Id, userData.UserName, userData.Email, userData.Avatar , userData.PostalAddress, userData.DedicatedGoogleCalendar ); diff --git a/test/src/YavscWorkInProgress.cs b/test/src/YavscWorkInProgress.cs index f137fed1..d80c719e 100644 --- a/test/src/YavscWorkInProgress.cs +++ b/test/src/YavscWorkInProgress.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Localization; using Microsoft.Extensions.OptionsModel; using Microsoft.Extensions.PlatformAbstractions; using Xunit; +using Xunit.Abstractions; using Yavsc; using Yavsc.Lib; using Yavsc.Models; @@ -24,21 +25,25 @@ namespace test public class YavscWorkInProgress : BaseTestContext { + ServerSideFixture _serverFixture; + ITestOutputHelper output; + public YavscWorkInProgress(ServerSideFixture serverFixture, ITestOutputHelper output) + { + this.output = output; + _serverFixture = serverFixture; + } + + [Fact] public void GitClone() { - AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", "Server=localhost;Port=5432;Database=YavscDev;Username=yavscdev;Password=admin;"); - ServiceCollection services = new ServiceCollection(); - - YavscMandatory.ConfigureServices(services, testprojectAssetPath, out configuration, out provider); + var dbc = _serverFixture._app.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; - var siteConfig = provider.GetRequiredService>().Value; - var dbc = provider.GetRequiredService(); var firstProject = dbc.Projects.FirstOrDefault(); Assert.NotNull (firstProject); - var clone = new GitClone(siteConfig.GitRepository); + var clone = new GitClone(_serverFixture._siteSetup.GitRepository); clone.Launch(firstProject); } }