diff options
author | crupest <crupest@outlook.com> | 2020-03-10 19:37:58 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-10 19:37:58 +0800 |
commit | 5eaacedda31da86116f25158bd07e5ad8954e7b2 (patch) | |
tree | b9165a233b00c4ab5be47f0ce786b64c178a9fdf /Timeline.Tests/IntegratedTests/IntegratedTestBase.cs | |
parent | 08b18564bb1c477b01384cb93d62f98cfcb83f48 (diff) | |
download | timeline-5eaacedda31da86116f25158bd07e5ad8954e7b2.tar.gz timeline-5eaacedda31da86116f25158bd07e5ad8954e7b2.tar.bz2 timeline-5eaacedda31da86116f25158bd07e5ad8954e7b2.zip |
...
Diffstat (limited to 'Timeline.Tests/IntegratedTests/IntegratedTestBase.cs')
-rw-r--r-- | Timeline.Tests/IntegratedTests/IntegratedTestBase.cs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs b/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs index dfde2ea5..66904629 100644 --- a/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs +++ b/Timeline.Tests/IntegratedTests/IntegratedTestBase.cs @@ -1,10 +1,13 @@ -using AutoMapper;
-using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection;
using System; using System.Collections.Generic;
using System.Net.Http; +using System.Text.Json;
+using System.Text.Json.Serialization;
using System.Threading.Tasks; +using Timeline.Models;
+using Timeline.Models.Converters;
using Timeline.Models.Http; using Timeline.Services;
using Timeline.Tests.Helpers; @@ -14,12 +17,6 @@ namespace Timeline.Tests.IntegratedTests { public abstract class IntegratedTestBase : IClassFixture<WebApplicationFactory<Startup>>, IDisposable { - static IntegratedTestBase()
- {
- FluentAssertions.AssertionOptions.AssertEquivalencyUsing(options =>
- options.Excluding(m => m.RuntimeType == typeof(UserInfoLinks)));
- } - protected TestApplication TestApp { get; } protected WebApplicationFactory<Startup> Factory => TestApp.Factory; @@ -63,12 +60,22 @@ namespace Timeline.Tests.IntegratedTests var userInfoList = new List<UserInfo>();
var userService = scope.ServiceProvider.GetRequiredService<IUserService>();
- var mapper = scope.ServiceProvider.GetRequiredService<IMapper>();
-
foreach (var user in users)
{
userService.CreateUser(user).Wait();
- userInfoList.Add(mapper.Map<UserInfo>(user));
+ }
+
+ using var client = CreateDefaultClient().Result;
+ var options = new JsonSerializerOptions
+ {
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase
+ };
+ options.Converters.Add(new JsonStringEnumConverter());
+ options.Converters.Add(new JsonDateTimeConverter());
+ foreach (var user in users)
+ {
+ var s = client.GetStringAsync($"/users/{user.Username}").Result;
+ userInfoList.Add(JsonSerializer.Deserialize<UserInfo>(s, options));
}
UserInfos = userInfoList;
|