Skip to content

Commit c664e43

Browse files
authored
Merge pull request #979 from lahma/update-test-libs
Update testing libraries and migrate FluentAssertions syntax +semver:fix
2 parents 875a4cd + 0ebb81f commit c664e43

19 files changed

+57
-73
lines changed

Directory.Packages.props

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
88
<PackageVersion Include="Bullseye" Version="4.1.1" />
99
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
10-
<PackageVersion Include="FakeItEasy" Version="6.2.1" />
11-
<PackageVersion Include="FluentAssertions" Version="4.19.2" />
10+
<PackageVersion Include="FakeItEasy" Version="8.3.0" />
11+
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
1212
<PackageVersion Include="FSharp.Core" Version="8.0.400" />
1313
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
1414
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
1515
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
16-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
16+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
1717
<PackageVersion Include="Nullable" Version="1.3.1" />
1818
<PackageVersion Include="ObjectLayoutInspector" Version="0.1.2" />
1919
<PackageVersion Include="SimpleExec" Version="12.0.0" />

YamlDotNet.Test/Core/EmitterTests.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ public void CompareOriginalAndEmittedText(string filename)
5757
var emittedText = EmittedTextFrom(originalEvents);
5858
var emittedEvents = ParsingEventsOf(emittedText);
5959

60-
emittedEvents.ShouldAllBeEquivalentTo(originalEvents,
61-
opt => opt.Excluding(@event => @event.Start)
62-
.Excluding(@event => @event.End)
63-
.Excluding((ParsingEvent @event) => ((DocumentEnd)@event).IsImplicit));
60+
emittedEvents.Should().BeEquivalentTo(originalEvents, opt => opt
61+
.Excluding(@event => @event.Start)
62+
.Excluding(@event => @event.End)
63+
.Excluding(@event => ((DocumentEnd)@event).IsImplicit)
64+
);
6465
}
6566

6667
private IList<ParsingEvent> ParsingEventsOf(string text)

YamlDotNet.Test/Core/InsertionQueueTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public void ShouldThrowExceptionWhenDequeuingEmptyContainer()
267267

268268
Action action = () => queue.Dequeue();
269269

270-
action.ShouldThrow<InvalidOperationException>();
270+
action.Should().Throw<InvalidOperationException>();
271271
}
272272

273273
[Fact]
@@ -279,7 +279,7 @@ public void ShouldThrowExceptionWhenDequeuingContainerThatBecomesEmpty()
279279
queue.Dequeue();
280280
Action action = () => queue.Dequeue();
281281

282-
action.ShouldThrow<InvalidOperationException>();
282+
action.Should().Throw<InvalidOperationException>();
283283
}
284284

285285
[Fact]
@@ -314,7 +314,7 @@ public void ShouldThrowExceptionWhenDequeuingAfterInserting()
314314
PerformTimes(2, queue.Dequeue);
315315
Action action = () => queue.Dequeue();
316316

317-
action.ShouldThrow<InvalidOperationException>();
317+
action.Should().Throw<InvalidOperationException>();
318318
}
319319

320320
[Fact]

YamlDotNet.Test/Core/LookAheadBufferTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public void ShouldThrowWhenSkippingBeyondCurrentBuffer()
206206
buffer.Peek(3);
207207
Action action = () => buffer.Skip(5);
208208

209-
action.ShouldThrow<ArgumentOutOfRangeException>();
209+
action.Should().Throw<ArgumentOutOfRangeException>();
210210
}
211211

212212
private static LookAheadBuffer CreateBuffer(TextReader reader, int capacity)

YamlDotNet.Test/RepresentationModel/YamlStreamTests.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
using YamlDotNet.Core;
3030
using YamlDotNet.Core.Events;
3131
using YamlDotNet.RepresentationModel;
32-
using YamlDotNet.Serialization.Schemas;
3332

3433
namespace YamlDotNet.Test.RepresentationModel
3534
{
@@ -57,7 +56,7 @@ public void AccessingAllNodesOnInfinitelyRecursiveDocumentThrows(string yaml)
5756

5857
var accessAllNodes = new Action(() => stream.Documents.Single().AllNodes.ToList());
5958

60-
accessAllNodes.ShouldThrow<MaximumRecursionLevelReachedException>("because the document is infinitely recursive.");
59+
accessAllNodes.Should().Throw<MaximumRecursionLevelReachedException>("because the document is infinitely recursive.");
6160
}
6261

6362
[Theory]

YamlDotNet.Test/Serialization/BufferedDeserialization/KeyValueTypeDiscriminatorTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121

2222
using System;
2323
using System.Collections.Generic;
24-
using System.Linq;
2524
using FluentAssertions;
2625
using Xunit;
27-
using YamlDotNet.Core;
2826
using YamlDotNet.Serialization;
2927
using YamlDotNet.Serialization.NamingConventions;
3028

YamlDotNet.Test/Serialization/BufferedDeserialization/TypeDiscriminatingNodeDeserializerTests.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
using System;
2323
using System.Collections.Generic;
24-
using System.Linq;
2524
using FluentAssertions;
2625
using Xunit;
2726
using YamlDotNet.Core;
@@ -47,10 +46,10 @@ public void TypeDiscriminatingNodeDeserializer_ThrowsWhen_MaxDepthExceeded()
4746

4847
Action act = () => bufferedDeserializer.Deserialize<object>(KubernetesServiceYaml);
4948
act
50-
.ShouldThrow<YamlException>()
49+
.Should().Throw<YamlException>()
5150
.WithMessage("Failed to buffer yaml node")
5251
.WithInnerException<ArgumentOutOfRangeException>()
53-
.Where(e => e.InnerException.Message.Contains("Parser buffer exceeded max depth"));
52+
.WithMessage("Parser buffer exceeded max depth*");
5453
}
5554

5655
[Fact]
@@ -68,10 +67,10 @@ public void TypeDiscriminatingNodeDeserializer_ThrowsWhen_MaxLengthExceeded()
6867

6968
Action act = () => bufferedDeserializer.Deserialize<object>(KubernetesServiceYaml);
7069
act
71-
.ShouldThrow<YamlException>()
70+
.Should().Throw<YamlException>()
7271
.WithMessage("Failed to buffer yaml node")
7372
.WithInnerException<ArgumentOutOfRangeException>()
74-
.Where(e => e.InnerException.Message.Contains("Parser buffer exceeded max length"));
73+
.WithMessage("Parser buffer exceeded max length*");
7574
}
7675

7776
public const string KubernetesServiceYaml = @"

YamlDotNet.Test/Serialization/BufferedDeserialization/UniqueKeyTypeDiscriminatorTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121

2222
using System;
2323
using System.Collections.Generic;
24-
using System.Linq;
2524
using FluentAssertions;
2625
using Xunit;
27-
using YamlDotNet.Core;
2826
using YamlDotNet.Serialization;
2927
using YamlDotNet.Serialization.NamingConventions;
3028

YamlDotNet.Test/Serialization/DateOnlyConverterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void Given_Yaml_WithInvalidDateTimeFormat_WithDefaultParameter_ReadYaml_S
7575

7676
Action action = () => { converter.ReadYaml(parser, typeof(DateOnly), null); };
7777

78-
action.ShouldThrow<FormatException>();
78+
action.Should().Throw<FormatException>();
7979
}
8080

8181
/// <summary>

YamlDotNet.Test/Serialization/DateTime8601ConverterTests.cs

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
// SOFTWARE.
2121

2222
using System;
23-
using System.Collections.Generic;
24-
using System.Linq;
25-
using System.Text;
26-
using System.Threading.Tasks;
27-
using FakeItEasy;
2823
using Xunit;
2924
using YamlDotNet.Core;
3025
using YamlDotNet.Serialization;

YamlDotNet.Test/Serialization/DateTimeConverterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void Given_Yaml_WithInvalidDateTimeFormat_WithDefaultParameters_ReadYaml_
7474

7575
Action action = () => { converter.ReadYaml(parser, typeof(DateTime), null); };
7676

77-
action.ShouldThrow<FormatException>();
77+
action.Should().Throw<FormatException>();
7878
}
7979

8080
/// <summary>

YamlDotNet.Test/Serialization/DateTimeOffsetConverterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void InvalidFormatThrowsException()
6666

6767
Action action = () => { converter.ReadYaml(parser, typeof(DateTimeOffset), null); };
6868

69-
action.ShouldThrow<FormatException>();
69+
action.Should().Throw<FormatException>();
7070
}
7171

7272
[Fact]

YamlDotNet.Test/Serialization/DeserializerTest.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ public void DeserializeWithDuplicateKeyChecking_YamlWithDuplicateKeys_ThrowsYaml
301301
.Build();
302302

303303
Action act = () => sut.Deserialize<Person>(yaml);
304-
act.ShouldThrow<YamlException>("Because there are duplicate name keys with concrete class");
304+
act.Should().Throw<YamlException>("Because there are duplicate name keys with concrete class");
305305
act = () => sut.Deserialize<IDictionary<object, object>>(yaml);
306-
act.ShouldThrow<YamlException>("Because there are duplicate name keys with dictionary");
306+
act.Should().Throw<YamlException>("Because there are duplicate name keys with dictionary");
307307

308308
var stream = Yaml.ReaderFrom("backreference.yaml");
309309
var parser = new MergingParser(new Parser(stream));
310310
act = () => sut.Deserialize<Dictionary<string, Dictionary<string, string>>>(parser);
311-
act.ShouldThrow<YamlException>("Because there are duplicate name keys with merging parser");
311+
act.Should().Throw<YamlException>("Because there are duplicate name keys with merging parser");
312312
}
313313

314314
[Fact]
@@ -325,14 +325,14 @@ public void DeserializeWithoutDuplicateKeyChecking_YamlWithDuplicateKeys_DoesNot
325325
.Build();
326326

327327
Action act = () => sut.Deserialize<Person>(yaml);
328-
act.ShouldNotThrow<YamlException>("Because duplicate key checking is not enabled");
328+
act.Should().NotThrow<YamlException>("Because duplicate key checking is not enabled");
329329
act = () => sut.Deserialize<IDictionary<object, object>>(yaml);
330-
act.ShouldNotThrow<YamlException>("Because duplicate key checking is not enabled");
330+
act.Should().NotThrow<YamlException>("Because duplicate key checking is not enabled");
331331

332332
var stream = Yaml.ReaderFrom("backreference.yaml");
333333
var parser = new MergingParser(new Parser(stream));
334334
act = () => sut.Deserialize<Dictionary<string, Dictionary<string, string>>>(parser);
335-
act.ShouldNotThrow<YamlException>("Because duplicate key checking is not enabled");
335+
act.Should().NotThrow<YamlException>("Because duplicate key checking is not enabled");
336336
}
337337

338338
[Fact]

YamlDotNet.Test/Serialization/HiddenPropertyTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void TestDuplicate()
9494
.Build();
9595

9696
Action action = () => { d.Deserialize<DuplicatePropertyDerived<string>>(yaml); };
97-
action.ShouldThrow<YamlException>();
97+
action.Should().Throw<YamlException>();
9898
}
9999
}
100100
}

0 commit comments

Comments
 (0)