From f7ec671a7422ea1fc6de4bb310fed3b4933f27e9 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 15 Jun 2020 00:05:02 +0800 Subject: refactor(back): Use generic host. --- Timeline.Tests/IntegratedTests/TokenTest.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'Timeline.Tests/IntegratedTests/TokenTest.cs') diff --git a/Timeline.Tests/IntegratedTests/TokenTest.cs b/Timeline.Tests/IntegratedTests/TokenTest.cs index 7b28746f..d1c31606 100644 --- a/Timeline.Tests/IntegratedTests/TokenTest.cs +++ b/Timeline.Tests/IntegratedTests/TokenTest.cs @@ -1,5 +1,4 @@ using FluentAssertions; -using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; using System.Collections.Generic; using System.Net.Http; @@ -17,12 +16,6 @@ namespace Timeline.Tests.IntegratedTests private const string CreateTokenUrl = "token/create"; private const string VerifyTokenUrl = "token/verify"; - public TokenTest(WebApplicationFactory factory) - : base(factory) - { - - } - private static async Task CreateUserTokenAsync(HttpClient client, string username, string password, int? expireOffset = null) { var response = await client.PostAsJsonAsync(CreateTokenUrl, new CreateTokenRequest { Username = username, Password = password, Expire = expireOffset }); @@ -106,7 +99,7 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateDefaultClient(); var token = (await CreateUserTokenAsync(client, "user1", "user1pw")).Token; - using (var scope = Factory.Services.CreateScope()) // UserService is scoped. + using (var scope = TestApp.Host.Services.CreateScope()) // UserService is scoped. { // create a user for test var userService = scope.ServiceProvider.GetRequiredService(); @@ -126,7 +119,7 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateDefaultClient(); var token = (await CreateUserTokenAsync(client, "user1", "user1pw")).Token; - using (var scope = Factory.Server.Host.Services.CreateScope()) // UserService is scoped. + using (var scope = TestApp.Host.Services.CreateScope()) // UserService is scoped. { var userService = scope.ServiceProvider.GetRequiredService(); await userService.DeleteUser("user1"); -- cgit v1.2.3