Skip to content

Commit edd878b

Browse files
authored
Migrate all tests to Fluent Assertions (#83)
1 parent ab3c5a2 commit edd878b

File tree

10 files changed

+42
-32
lines changed

10 files changed

+42
-32
lines changed

test/Microsoft.OpenApi.Readers.Tests/ParameterTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Collections.Generic;
99
using System.Linq;
1010
using System.Text;
11+
using FluentAssertions;
1112
using Microsoft.OpenApi.Models;
1213
using Xunit;
1314

@@ -116,7 +117,7 @@ public void SerializeArrays(ParameterStyle style, bool explode, string[] value,
116117
};
117118

118119
var actual = SerializeParameterValue(parameter, value);
119-
Assert.Equal(expected, actual);
120+
actual.Should().Be(expected);
120121
}
121122

122123
[Theory]
@@ -130,7 +131,7 @@ public void SerializeEscapedStrings(string value, string expected)
130131
};
131132

132133
var actual = SerializeParameterValue(parameter, value);
133-
Assert.Equal(expected, actual);
134+
actual.Should().Be(expected);
134135
}
135136

136137
// format="space-delimited" type="array" explode=false bar=a b
@@ -152,7 +153,7 @@ public void SerializeMaps(ParameterStyle style, bool explode, string expected)
152153
};
153154

154155
var actual = SerializeParameterValue(parameter, value);
155-
Assert.Equal(expected, actual);
156+
actual.Should().Be(expected);
156157
}
157158

158159
// Is it possible to write code based on the information in Parameter
@@ -236,7 +237,7 @@ public void SerializePrefixedStrings(ParameterStyle style, string value, string
236237
};
237238

238239
var actual = SerializeParameterValue(parameter, value);
239-
Assert.Equal(expected, actual);
240+
actual.Should().Be(expected);
240241
}
241242

242243
[Theory]
@@ -246,7 +247,7 @@ public void SerializeStrings(string value, string expected)
246247
var parameter = new OpenApiParameter();
247248

248249
var actual = SerializeParameterValue(parameter, value);
249-
Assert.Equal(expected, actual);
250+
actual.Should().Be(expected);
250251
}
251252

252253
private string SerializeValues(

test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Collections.Generic;
8+
using FluentAssertions;
89
using Microsoft.OpenApi.Any;
910
using Microsoft.OpenApi.Models;
1011
using Xunit;
@@ -39,7 +40,7 @@ public void SerializeBasicContactWorks(OpenApiSpecVersion version,
3940
// Assert
4041
actual = actual.MakeLineBreaksEnvironmentNeutral();
4142
expected = expected.MakeLineBreaksEnvironmentNeutral();
42-
Assert.Equal(expected, actual);
43+
actual.Should().Be(expected);
4344
}
4445

4546
[Theory]
@@ -62,7 +63,7 @@ public void SerializeAdvanceContactAsJsonWorks(OpenApiSpecVersion version)
6263
// Assert
6364
actual = actual.MakeLineBreaksEnvironmentNeutral();
6465
expected = expected.MakeLineBreaksEnvironmentNeutral();
65-
Assert.Equal(expected, actual);
66+
actual.Should().Be(expected);
6667
}
6768

6869
[Theory]
@@ -83,7 +84,7 @@ public void SerializeAdvanceContactAsYamlWorks(OpenApiSpecVersion version)
8384
// Assert
8485
actual = actual.MakeLineBreaksEnvironmentNeutral();
8586
expected = expected.MakeLineBreaksEnvironmentNeutral();
86-
Assert.Equal(expected, actual);
87+
actual.Should().Be(expected);
8788
}
8889
}
8990
}

test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using FluentAssertions;
67
using Microsoft.OpenApi.Models;
78
using Xunit;
89

@@ -30,7 +31,7 @@ public void SerializeBasicEncodingAsV3Works(OpenApiFormat format, string expecte
3031
// Assert
3132
actual = actual.MakeLineBreaksEnvironmentNeutral();
3233
expected = expected.MakeLineBreaksEnvironmentNeutral();
33-
Assert.Equal(expected, actual);
34+
actual.Should().Be(expected);
3435
}
3536

3637
[Fact]
@@ -51,7 +52,7 @@ public void SerializeAdvanceEncodingAsV3JsonWorks()
5152
// Assert
5253
actual = actual.MakeLineBreaksEnvironmentNeutral();
5354
expected = expected.MakeLineBreaksEnvironmentNeutral();
54-
Assert.Equal(expected, actual);
55+
actual.Should().Be(expected);
5556
}
5657

5758
[Fact]
@@ -70,7 +71,7 @@ public void SerializeAdvanceEncodingAsV3YamlWorks()
7071
// Assert
7172
actual = actual.MakeLineBreaksEnvironmentNeutral();
7273
expected = expected.MakeLineBreaksEnvironmentNeutral();
73-
Assert.Equal(expected, actual);
74+
actual.Should().Be(expected);
7475
}
7576
}
7677
}

test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System;
7+
using FluentAssertions;
78
using Microsoft.OpenApi.Models;
89
using Xunit;
910

@@ -30,7 +31,7 @@ public void SerializeBasicExternalDocsAsV3Works(OpenApiFormat format, string exp
3031
// Assert
3132
actual = actual.MakeLineBreaksEnvironmentNeutral();
3233
expected = expected.MakeLineBreaksEnvironmentNeutral();
33-
Assert.Equal(expected, actual);
34+
actual.Should().Be(expected);
3435
}
3536

3637
[Fact]
@@ -49,7 +50,7 @@ public void SerializeAdvanceExDocsAsV3JsonWorks()
4950
// Assert
5051
actual = actual.MakeLineBreaksEnvironmentNeutral();
5152
expected = expected.MakeLineBreaksEnvironmentNeutral();
52-
Assert.Equal(expected, actual);
53+
actual.Should().Be(expected);
5354
}
5455

5556
[Fact]
@@ -66,7 +67,7 @@ public void SerializeAdvanceExDocsAsV3YamlWorks()
6667
// Assert
6768
actual = actual.MakeLineBreaksEnvironmentNeutral();
6869
expected = expected.MakeLineBreaksEnvironmentNeutral();
69-
Assert.Equal(expected, actual);
70+
actual.Should().Be(expected);
7071
}
7172

7273
#endregion

test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Collections.Generic;
8+
using FluentAssertions;
89
using Microsoft.OpenApi.Any;
910
using Microsoft.OpenApi.Models;
1011
using Xunit;
@@ -54,7 +55,7 @@ public void SerializeBasicInfoAsJsonWorks(OpenApiSpecVersion version, string exp
5455
// Assert
5556
actual = actual.MakeLineBreaksEnvironmentNeutral();
5657
expected = expected.MakeLineBreaksEnvironmentNeutral();
57-
Assert.Equal(expected, actual);
58+
actual.Should().Be(expected);
5859
}
5960

6061
public static IEnumerable<object[]> BasicInfoYamlExpect()
@@ -81,7 +82,7 @@ public void SerializeBasicInfoAsYamlWorks(OpenApiSpecVersion version, string exp
8182
// Assert
8283
actual = actual.MakeLineBreaksEnvironmentNeutral();
8384
expected = expected.MakeLineBreaksEnvironmentNeutral();
84-
Assert.Equal(expected, actual);
85+
actual.Should().Be(expected);
8586
}
8687

8788
public static IEnumerable<object[]> AdvanceInfoJsonExpect()
@@ -124,7 +125,7 @@ public void SerializeAdvanceInfoAsJsonWorks(OpenApiSpecVersion version, string e
124125
// Assert
125126
actual = actual.MakeLineBreaksEnvironmentNeutral();
126127
expected = expected.MakeLineBreaksEnvironmentNeutral();
127-
Assert.Equal(expected, actual);
128+
actual.Should().Be(expected);
128129
}
129130

130131
public static IEnumerable<object[]> AdvanceInfoYamlExpect()
@@ -163,7 +164,7 @@ public void SerializeAdvanceInfoAsYamlWorks(OpenApiSpecVersion version, string e
163164
// Assert
164165
actual = actual.MakeLineBreaksEnvironmentNeutral();
165166
expected = expected.MakeLineBreaksEnvironmentNeutral();
166-
Assert.Equal(expected, actual);
167+
actual.Should().Be(expected);
167168
}
168169
}
169170
}

test/Microsoft.OpenApi.Tests/Models/OpenApiLicenseTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Collections.Generic;
8+
using FluentAssertions;
89
using Microsoft.OpenApi.Any;
910
using Microsoft.OpenApi.Models;
1011
using Xunit;
@@ -41,7 +42,7 @@ public void SerializeBasicLicenseAsJsonWorks(OpenApiSpecVersion version)
4142
// Assert
4243
actual = actual.MakeLineBreaksEnvironmentNeutral();
4344
expected = expected.MakeLineBreaksEnvironmentNeutral();
44-
Assert.Equal(expected, actual);
45+
actual.Should().Be(expected);
4546
}
4647

4748
[Theory]
@@ -58,7 +59,7 @@ public void SerializeBasicLicenseAsYamlWorks(OpenApiSpecVersion version)
5859
// Assert
5960
actual = actual.MakeLineBreaksEnvironmentNeutral();
6061
expected = expected.MakeLineBreaksEnvironmentNeutral();
61-
Assert.Equal(expected, actual);
62+
actual.Should().Be(expected);
6263
}
6364

6465
[Theory]
@@ -80,7 +81,7 @@ public void SerializeAdvanceLicenseAsJsonWorks(OpenApiSpecVersion version)
8081
// Assert
8182
actual = actual.MakeLineBreaksEnvironmentNeutral();
8283
expected = expected.MakeLineBreaksEnvironmentNeutral();
83-
Assert.Equal(expected, actual);
84+
actual.Should().Be(expected);
8485
}
8586

8687
[Theory]
@@ -100,7 +101,7 @@ public void SerializeAdvanceLicenseAsYamlWorks(OpenApiSpecVersion version)
100101
// Assert
101102
actual = actual.MakeLineBreaksEnvironmentNeutral();
102103
expected = expected.MakeLineBreaksEnvironmentNeutral();
103-
Assert.Equal(expected, actual);
104+
actual.Should().Be(expected);
104105
}
105106
}
106107
}

test/Microsoft.OpenApi.Tests/Models/OpenApiMediaTypeTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System.Collections.Generic;
7+
using FluentAssertions;
78
using Microsoft.OpenApi.Any;
89
using Microsoft.OpenApi.Models;
910
using Xunit;
@@ -57,7 +58,7 @@ public void SerializeAdvanceMediaTypeAsV3JsonWorks()
5758
// Assert
5859
actual = actual.MakeLineBreaksEnvironmentNeutral();
5960
expected = expected.MakeLineBreaksEnvironmentNeutral();
60-
Assert.Equal(expected, actual);
61+
actual.Should().Be(expected);
6162
}
6263

6364
[Fact]
@@ -79,7 +80,7 @@ public void SerializeAdvanceMediaTypeAsV3YamlWorks()
7980
// Assert
8081
actual = actual.MakeLineBreaksEnvironmentNeutral();
8182
expected = expected.MakeLineBreaksEnvironmentNeutral();
82-
Assert.Equal(expected, actual);
83+
actual.Should().Be(expected);
8384
}
8485
}
8586
}

test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System.Collections.Generic;
7+
using FluentAssertions;
78
using Microsoft.OpenApi.Any;
89
using Microsoft.OpenApi.Models;
910
using Xunit;
@@ -41,7 +42,7 @@ public void SerializeBasicTagWorks(OpenApiSpecVersion version,
4142
// Assert
4243
actual = actual.MakeLineBreaksEnvironmentNeutral();
4344
expected = expected.MakeLineBreaksEnvironmentNeutral();
44-
Assert.Equal(expected, actual);
45+
actual.Should().Be(expected);
4546
}
4647

4748
[Theory]
@@ -67,7 +68,7 @@ public void SerializeAdvancedTagAsJsonWorks(OpenApiSpecVersion version)
6768
// Assert
6869
actual = actual.MakeLineBreaksEnvironmentNeutral();
6970
expected = expected.MakeLineBreaksEnvironmentNeutral();
70-
Assert.Equal(expected, actual);
71+
actual.Should().Be(expected);
7172
}
7273

7374
[Theory]
@@ -90,7 +91,7 @@ public void SerializeAdvancedTagAsYamlWorks(OpenApiSpecVersion version)
9091
// Assert
9192
actual = actual.MakeLineBreaksEnvironmentNeutral();
9293
expected = expected.MakeLineBreaksEnvironmentNeutral();
93-
Assert.Equal(expected, actual);
94+
actual.Should().Be(expected);
9495
}
9596
}
9697
}

test/Microsoft.OpenApi.Tests/Models/OpenApiXmlTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Collections.Generic;
8+
using FluentAssertions;
89
using Microsoft.OpenApi.Any;
910
using Microsoft.OpenApi.Models;
1011
using Xunit;
@@ -68,7 +69,7 @@ public void SerializeAdvancedXmlAsJsonWorks(OpenApiSpecVersion version)
6869
// Assert
6970
actual = actual.MakeLineBreaksEnvironmentNeutral();
7071
expected = expected.MakeLineBreaksEnvironmentNeutral();
71-
Assert.Equal(expected, actual);
72+
actual.Should().Be(expected);
7273
}
7374

7475
[Theory]
@@ -91,7 +92,7 @@ public void SerializeAdvancedXmlAsYamlWorks(OpenApiSpecVersion version)
9192
// Assert
9293
actual = actual.MakeLineBreaksEnvironmentNeutral();
9394
expected = expected.MakeLineBreaksEnvironmentNeutral();
94-
Assert.Equal(expected, actual);
95+
actual.Should().Be(expected);
9596
}
9697
}
9798
}

test/Microsoft.OpenApi.Tests/Serialization/OpenApiExternalDocsExtensionsTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.IO;
8+
using FluentAssertions;
89
using Microsoft.OpenApi.Models;
910
using Xunit;
1011

@@ -31,7 +32,7 @@ public void SerializeBasicExternalDocsAsV3Works(OpenApiFormat format, string exp
3132
// Assert
3233
expected = expected.MakeLineBreaksEnvironmentNeutral();
3334
actual = actual.MakeLineBreaksEnvironmentNeutral();
34-
Assert.Equal(expected, actual);
35+
actual.Should().Be(expected);
3536
}
3637

3738
[Fact]
@@ -50,7 +51,7 @@ public void SerializeAdvanceExDocssAsV3JsonWorks()
5051
// Assert
5152
expected = expected.MakeLineBreaksEnvironmentNeutral();
5253
actual = actual.MakeLineBreaksEnvironmentNeutral();
53-
Assert.Equal(expected, actual);
54+
actual.Should().Be(expected);
5455
}
5556

5657
[Fact]
@@ -67,7 +68,7 @@ public void SerializeAdvanceExDocssAsV3YamlWorks()
6768
// Assert
6869
expected = expected.MakeLineBreaksEnvironmentNeutral();
6970
actual = actual.MakeLineBreaksEnvironmentNeutral();
70-
Assert.Equal(expected, actual);
71+
actual.Should().Be(expected);
7172
}
7273

7374
#endregion

0 commit comments

Comments
 (0)