|
4 | 4 | using System.Linq; |
5 | 5 |
|
6 | 6 | using global::AutoFixture; |
7 | | - |
8 | | - using JetBrains.Annotations; |
| 7 | + using global::AutoFixture.Kernel; |
9 | 8 |
|
10 | 9 | using Objectivity.AutoFixture.XUnit2.Core.SpecimenBuilders; |
11 | 10 |
|
12 | 11 | using Xunit; |
13 | 12 |
|
14 | 13 | internal static class FixtureAssertionExtensions |
15 | 14 | { |
16 | | - [AssertionMethod] |
17 | 15 | internal static void ShouldNotThrowOnRecursion(this IFixture fixture) |
18 | 16 | { |
19 | 17 | // Ensure there is no behavior for throwing exception on recursive structures. |
20 | | - Assert.DoesNotContain(fixture.Behaviors, b => b is ThrowingRecursionBehavior); |
| 18 | + Assert.DoesNotContain(fixture.Behaviors, IsSpecimenBuilderTransformation<ThrowingRecursionBehavior>); |
21 | 19 | } |
22 | 20 |
|
23 | | - [AssertionMethod] |
24 | 21 | internal static void ShouldOmitRecursion(this IFixture fixture) |
25 | 22 | { |
26 | 23 | // Ensure there is a behavior added for omitting recursive types |
27 | 24 | // on default recursion depth. |
28 | | - Assert.Single(fixture.Behaviors, b => b is OmitOnRecursionBehavior); |
| 25 | + Assert.Single(fixture.Behaviors, IsSpecimenBuilderTransformation<OmitOnRecursionBehavior>); |
29 | 26 | } |
30 | 27 |
|
31 | | - [AssertionMethod] |
32 | 28 | internal static void ShouldNotIgnoreVirtualMembers(this IFixture fixture) |
33 | 29 | { |
34 | | - Assert.DoesNotContain(fixture.Customizations, s => s is IgnoreVirtualMembersSpecimenBuilder); |
| 30 | + Assert.DoesNotContain(fixture.Customizations, IsSpecimenBuilder<IgnoreVirtualMembersSpecimenBuilder>); |
35 | 31 | } |
36 | 32 |
|
37 | | - [AssertionMethod] |
38 | 33 | internal static void ShouldIgnoreVirtualMembers(this IFixture fixture) |
39 | 34 | { |
40 | | - Assert.Single(fixture.Customizations, s => s is IgnoreVirtualMembersSpecimenBuilder); |
| 35 | + Assert.Single(fixture.Customizations, IsSpecimenBuilder<IgnoreVirtualMembersSpecimenBuilder>); |
41 | 36 | } |
42 | 37 |
|
43 | | - [AssertionMethod] |
44 | 38 | internal static void ShouldIgnoreVirtualMembers(this IFixture fixture, Type reflectedType) |
45 | 39 | { |
46 | | - Assert.Single( |
47 | | - fixture.Customizations.OfType<IgnoreVirtualMembersSpecimenBuilder>(), |
48 | | - c => c.ReflectedType == reflectedType); |
| 40 | + bool IsReflectedOnType(IgnoreVirtualMembersSpecimenBuilder c) => c.ReflectedType == reflectedType; |
| 41 | + Assert.Single(fixture.Customizations.OfType<IgnoreVirtualMembersSpecimenBuilder>(), IsReflectedOnType); |
49 | 42 | } |
| 43 | + |
| 44 | + private static bool IsSpecimenBuilderTransformation<T>(ISpecimenBuilderTransformation b) |
| 45 | + where T : ISpecimenBuilderTransformation => b is T; |
| 46 | + |
| 47 | + private static bool IsSpecimenBuilder<T>(ISpecimenBuilder s) |
| 48 | + where T : ISpecimenBuilder => s is T; |
50 | 49 | } |
51 | 50 | } |
0 commit comments