Skip to content

Commit d86c035

Browse files
Update dependency FluentAssertions to v6 (#554)
* Update dependency FluentAssertions to v6 * Fix compilation after FluentAssertions upgrade * Remove FluentAssertions from FluentNHibernate.Testing +semver:patch Co-authored-by: Alex Zaytsev <[email protected]>
1 parent 9ee89b2 commit d86c035

File tree

7 files changed

+21
-38
lines changed

7 files changed

+21
-38
lines changed

src/FluentNHibernate.Specs/Diagnostics/Registration_diagnostics_specs.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public class when_automapping_with_diagnostics_enabled
114114
results.AutomappingSkippedTypes.Select(x => x.Reason).Should().Contain("Skipped by result of IAutomappingConfiguration.ShouldMap(Type)");
115115

116116
It should_not_include_a_skipped_entry_for_used_types = () =>
117-
results.AutomappingSkippedTypes.Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
117+
results.AutomappingSkippedTypes.Select(x => x.Type).Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
118118

119119
It should_include_all_unskipped_types_in_the_candidate_list = () =>
120120
results.AutomappingCandidateTypes.Should().OnlyContain(type => type.Equals(typeof(Second)) || type.Equals(typeof(Third)));
@@ -160,7 +160,7 @@ public class when_automapping_with_diagnostics_enabled_and_excluding_by_where
160160
results.AutomappingSkippedTypes.Select(x => x.Reason).Should().Contain("Skipped by Where clause");
161161

162162
It should_not_include_a_skipped_entry_for_used_types = () =>
163-
results.AutomappingSkippedTypes.Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
163+
results.AutomappingSkippedTypes.Select(x => x.Type).Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
164164

165165
It should_include_all_unskipped_types_in_the_candidate_list = () =>
166166
results.AutomappingCandidateTypes.Should().OnlyContain(type => type.Equals(typeof(Second)) || type.Equals(typeof(Third)));
@@ -198,7 +198,7 @@ public class when_automapping_with_diagnostics_enabled_and_excluding_by_IgnoreBa
198198
results.AutomappingSkippedTypes.Select(x => x.Reason).Should().Contain("Skipped by IgnoreBase");
199199

200200
It should_not_include_a_skipped_entry_for_used_types = () =>
201-
results.AutomappingSkippedTypes.Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
201+
results.AutomappingSkippedTypes.Select(x => x.Type).Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
202202

203203
It should_include_all_unskipped_types_in_the_candidate_list = () =>
204204
results.AutomappingCandidateTypes.Should().OnlyContain(type => type.Equals(typeof(Second)) || type.Equals(typeof(Third)));
@@ -236,7 +236,7 @@ public class when_automapping_with_diagnostics_enabled_and_excluding_by_generic_
236236
results.AutomappingSkippedTypes.Select(x => x.Reason).Should().Contain("Skipped by IgnoreBase");
237237

238238
It should_not_include_a_skipped_entry_for_used_types = () =>
239-
results.AutomappingSkippedTypes.Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
239+
results.AutomappingSkippedTypes.Select(x => x.Type).Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
240240

241241
It should_include_all_unskipped_types_in_the_candidate_list = () =>
242242
results.AutomappingCandidateTypes.Should().OnlyContain(type => type.Equals(typeof(Second)) || type.Equals(typeof(Third)));
@@ -273,7 +273,7 @@ public class when_automapping_with_diagnostics_enabled_and_excluding_by_layer_su
273273
results.AutomappingSkippedTypes.Select(x => x.Reason).Should().Contain("Skipped by IAutomappingConfiguration.AbstractClassIsLayerSupertype(Type)");
274274

275275
It should_not_include_a_skipped_entry_for_used_types = () =>
276-
results.AutomappingSkippedTypes.Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
276+
results.AutomappingSkippedTypes.Select(x => x.Type).Should().NotContain(new Type[] { typeof(Second), typeof(Third) });
277277

278278
It should_include_all_unskipped_types_in_the_candidate_list = () =>
279279
results.AutomappingCandidateTypes.Should().OnlyContain(type => type.Equals(typeof(Second)) || type.Equals(typeof(Third)));
@@ -318,7 +318,7 @@ public class when_automapping_with_diagnostics_enabled_and_excluding_by_explicit
318318
results.AutomappingSkippedTypes.Select(x => x.Reason).Should().Contain("Skipped by IAutomappingConfiguration.IsComponent(Type)");
319319

320320
It should_not_include_a_skipped_entry_for_used_types = () =>
321-
results.AutomappingSkippedTypes.Should().NotContain(new Type[] { typeof(Second), typeof(Third) } );
321+
results.AutomappingSkippedTypes.Select(x => x.Type).Should().NotContain(new Type[] { typeof(Second), typeof(Third) } );
322322

323323
It should_include_all_unskipped_types_in_the_candidate_list = () =>
324324
results.AutomappingCandidateTypes.Should().OnlyContain(type => type.Equals(typeof(Second)) || type.Equals(typeof(Third)));

src/FluentNHibernate.Specs/FluentNHibernate.Specs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
14-
<PackageReference Include="FluentAssertions" Version="4.19.4" />
14+
<PackageReference Include="FluentAssertions" Version="6.7.0" />
1515
<PackageReference Include="Machine.Specifications" Version="1.1.0" />
1616
<PackageReference Include="Machine.Specifications.Runner.VisualStudio" Version="2.10.2" />
1717
</ItemGroup>

src/FluentNHibernate.Testing/ConventionFinderTests/AddingTypeTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using FluentNHibernate.Conventions;
33
using FluentNHibernate.Conventions.Instances;
44
using NUnit.Framework;
5-
using FluentAssertions;
65

76
namespace FluentNHibernate.Testing.ConventionFinderTests
87
{
@@ -31,7 +30,6 @@ public void AddingSingleShouldntThrowIfHasIConventionFinderConstructor()
3130
Action act = () => finder.Add<ConventionWithIConventionFinderConstructor>();
3231

3332
act.ShouldNotThrow();
34-
3533
}
3634

3735
[Test]

src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.1.0" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
2323
<PackageReference Include="FakeItEasy" Version="7.3.1" />
24-
<PackageReference Include="FluentAssertions" Version="4.19.4" />
2524
<PackageReference Include="NUnit" Version="3.13.3" />
2625
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
2726
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.116" />

src/FluentNHibernate.Testing/Infrastructure/ContainerTester.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using FluentNHibernate.Infrastructure;
33
using NUnit.Framework;
4-
using FluentAssertions;
54

65
namespace FluentNHibernate.Testing.Infrastructure
76
{

src/FluentNHibernate.Testing/SpecificationExtensions.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace FluentNHibernate.Testing
99
{
10-
public delegate void MethodThatThrows();
11-
1210
public static class SpecificationExtensions
1311
{
1412
public static void ShouldBeFalse(this bool condition)
@@ -240,31 +238,19 @@ public static void ShouldNotStartWith(this string actual, string expected)
240238
StringAssert.DoesNotStartWith(expected, actual);
241239
}
242240

243-
public static void ShouldContainErrorMessage(this Exception exception, string expected)
241+
public static void WithMessage(this Exception exception, string expected)
244242
{
245-
StringAssert.Contains(expected, exception.Message);
243+
Assert.That(exception.Message, Is.EqualTo(expected));
246244
}
247245

248-
public static Exception ShouldBeThrownBy(this Type exceptionType, MethodThatThrows method)
246+
public static Exception ShouldThrow<TException>(this Action action) where TException : Exception
249247
{
250-
Exception exception = null;
251-
252-
try
253-
{
254-
method();
255-
}
256-
catch (Exception e)
257-
{
258-
Assert.AreEqual(exceptionType, e.GetType());
259-
exception = e;
260-
}
261-
262-
if (exception == null)
263-
{
264-
Assert.Fail(String.Format("Expected {0} to be thrown.", exceptionType.FullName));
265-
}
248+
return Assert.Throws<TException>(new TestDelegate(action));
249+
}
266250

267-
return exception;
251+
public static void ShouldNotThrow(this Action action)
252+
{
253+
Assert.DoesNotThrow(new TestDelegate(action));
268254
}
269255

270256
public static void ShouldEqualSqlDate(this DateTime actual, DateTime expected)

src/FluentNHibernate.Testing/Testing/PersistenceSpecificationTester.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public void should_not_be_equal_without_the_equality_comparer()
141141
{
142142
spec = new PersistenceSpecification<Cat>(sessionSource);
143143

144-
typeof(ApplicationException).ShouldBeThrownBy(() =>
145-
spec.CheckList(x => x.AllKittens, cat.AllKittens).VerifyTheMappings());
144+
Action act = () => spec.CheckList(x => x.AllKittens, cat.AllKittens).VerifyTheMappings();
145+
act.ShouldThrow<ApplicationException>();
146146
}
147147

148148
[Test]
@@ -163,7 +163,8 @@ public void Can_test_enumerable()
163163
spec.CheckEnumerable(x => x.EnumerableOfKittens, (cat, kitten) => cat.AddKitten(kitten), kittens);
164164
#pragma warning restore 618,612
165165

166-
typeof(ApplicationException).ShouldBeThrownBy(() => spec.VerifyTheMappings());
166+
Action act = () => spec.VerifyTheMappings();
167+
act.ShouldThrow<ApplicationException>();
167168
}
168169

169170
[Test]
@@ -232,8 +233,8 @@ public void Should_reject_classes_without_a_parameterless_constructor()
232233
{
233234
var _spec = new PersistenceSpecification<NoParameterlessConstructorClass>(sessionSource);
234235

235-
typeof(MissingConstructorException).ShouldBeThrownBy(() =>
236-
_spec.VerifyTheMappings());
236+
Action act = () => _spec.VerifyTheMappings();
237+
act.ShouldThrow<MissingConstructorException>();
237238
}
238239

239240
[Test]

0 commit comments

Comments
 (0)