From dc54df19a69381f852e18dba949096e01316834c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 7 Jul 2025 11:51:02 +0100 Subject: [PATCH] re testing --- test/isn.tests/PushTest.cs | 11 ----------- test/isnd.tests/UnitTestWebHost.cs | 2 +- test/isnd.tests/WebServerFixture.cs | 18 ++++++++++++++---- .../Yavsc.Abstract.1.0.8.nupkg | Bin test/isnd.tests/isnd.tests.csproj | 1 + 5 files changed, 16 insertions(+), 16 deletions(-) rename test/{data/packages => isnd.tests}/Yavsc.Abstract.1.0.8.nupkg (100%) diff --git a/test/isn.tests/PushTest.cs b/test/isn.tests/PushTest.cs index 304bfd9..74f35d4 100644 --- a/test/isn.tests/PushTest.cs +++ b/test/isn.tests/PushTest.cs @@ -42,17 +42,6 @@ namespace isn.tests var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/")); Assert.True(pub != null); } - [Fact] - public void TestSetApiKey() - { - string source = "http://localhost:3002/v3/index.json"; - - var setting = Settings.Create(); - setting.Sources[source] = new SourceSettings{ Url=source }; - string testingKey = "CfDJ8LF3SbIJ4FJAgs7uIQKhdCAYCNVXRwU6TEoaXOo1_ZpG2u8TCGFP2z13hw9xR0LC0gdbr1QGwNndiXUl4DI74nxyBi-T1oC33PWtE-5vgiJWeCH223PYtoSEdzDiWovwJZWJbQON0WqoG8vSfbrBXTmicD6oxF4ghwXXexY0RiRR"; - - Assert.Equal(testingKey, setting.Sources[source].ApiKey); - } } } \ No newline at end of file diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs index eec9fb8..dfe83ee 100644 --- a/test/isnd.tests/UnitTestWebHost.cs +++ b/test/isnd.tests/UnitTestWebHost.cs @@ -183,7 +183,7 @@ namespace isnd.host.tests PackageUpdateResource pushRes = await repository.GetResourceAsync(); SymbolPackageUpdateResourceV3 symbolPackageResource = await repository.GetResourceAsync(); - await pushRes.Push(new List{ "../../../../../src/isn.abst/bin/Release/isn.abst.1.0.1.nupkg" }, null, + await pushRes.Push(new List{ "../../../Yavsc.Abstract.1.0.8.nupkg" }, null, 5000, false, GetApiKey, GetSymbolsApiKey, false, false, symbolPackageResource, logger); } diff --git a/test/isnd.tests/WebServerFixture.cs b/test/isnd.tests/WebServerFixture.cs index 75e1095..46e0452 100644 --- a/test/isnd.tests/WebServerFixture.cs +++ b/test/isnd.tests/WebServerFixture.cs @@ -33,7 +33,6 @@ namespace isnd.tests public IDataProtector DataProtector { get; private set; } - public ApplicationDbContext dbContext { get; private set; } public string TestingUserName { get; private set; } public string ProtectedTestingApiKey { get; internal set; } @@ -80,15 +79,18 @@ namespace isnd.tests DataProtector = Host.Services.GetRequiredService() .CreateProtector(siteSettings.ProtectionTitle); + using IServiceScope scope = Host.Services.CreateScope(); + ApplicationDbContext dbContext = + scope.ServiceProvider.GetRequiredService(); - dbContext = Host.Services.GetRequiredService(); + TestingUserName = "Tester"; TestingUser = dbContext.Users.FirstOrDefault(u => u.UserName == TestingUserName); EnsureUser(TestingUserName); var testKey = dbContext.ApiKeys.FirstOrDefault(k => k.UserId == TestingUser.Id); if (testKey == null) { - var keyProvider = Host.Services.GetService(); + var keyProvider = scope.ServiceProvider.GetService(); var apiKeyQuery = new Data.ApiKeys.CreateModel { Name = "Testing Key", @@ -111,7 +113,12 @@ namespace isnd.tests { if (TestingUser == null) { - var userManager = Host.Services.GetRequiredService>(); + using IServiceScope scope = Host.Services.CreateScope(); + + var userManager = + scope.ServiceProvider.GetRequiredService>(); + + TestingUser = new ApplicationUser { UserName = testingUserName @@ -120,6 +127,9 @@ namespace isnd.tests var result = userManager.CreateAsync(TestingUser).Result; Assert.True(result.Succeeded); + + ApplicationDbContext dbContext = + scope.ServiceProvider.GetRequiredService(); TestingUser = dbContext.Users.FirstOrDefault(u => u.UserName == testingUserName); } } diff --git a/test/data/packages/Yavsc.Abstract.1.0.8.nupkg b/test/isnd.tests/Yavsc.Abstract.1.0.8.nupkg similarity index 100% rename from test/data/packages/Yavsc.Abstract.1.0.8.nupkg rename to test/isnd.tests/Yavsc.Abstract.1.0.8.nupkg diff --git a/test/isnd.tests/isnd.tests.csproj b/test/isnd.tests/isnd.tests.csproj index 086e5dc..ddc9157 100644 --- a/test/isnd.tests/isnd.tests.csproj +++ b/test/isnd.tests/isnd.tests.csproj @@ -18,5 +18,6 @@ +