-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMavenlinkTests.cs
71 lines (58 loc) · 1.84 KB
/
MavenlinkTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using FluentAssertions;
using FluentSerializer.Core.Constants;
using FluentSerializer.Core.Factories;
using FluentSerializer.Core.Naming;
using FluentSerializer.Core.TestUtils.Extensions;
using FluentSerializer.Json.Converter.DefaultJson.Extensions;
using FluentSerializer.Json.Converting;
using FluentSerializer.Json.Extensions;
using FluentSerializer.Json.Services;
using FluentSerializer.UseCase.Mavenlink.Models;
using FluentSerializer.UseCase.Mavenlink.Models.Entities;
using System;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using Xunit;
namespace FluentSerializer.UseCase.Mavenlink;
public sealed partial class MavenlinkTests
{
private readonly IJsonSerializer _sut;
public MavenlinkTests()
{
_sut = SerializerFactory.For
.Json(static configuration =>
{
configuration.DefaultNamingStrategy = Names.Use.SnakeCase;
configuration.DefaultConverters.Use(Converter.For.Json());
configuration.NewLine = LineEndings.LineFeed;
})
.UseProfilesFromAssembly<MavenlinkTests>();
}
[Fact,
Trait("Category", "UseCase")]
public async Task Serialize()
{
// Arrange
var expected = await File.ReadAllTextAsync("./MavenlinkTests.Serialize.json");
var example = ProjectRequestExample;
// Act
var result = _sut.Serialize(example);
// Assert
result.ShouldBeBinaryEquatableTo(expected);
}
[Fact,
Trait("Category", "UseCase")]
public async Task Deserialize()
{
// Arrange
var expected = UserResponseExample;
var example = await File.ReadAllTextAsync("./MavenlinkTests.Deserialize.json");
// Act
var result = _sut.Deserialize<Response<User>>(example);
// Assert
result.Should().BeEquivalentTo(expected);
}
private static DateTime CreateDate(string dateString) => DateTime.ParseExact(
dateString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
}