Skip to content

Commit b5c0562

Browse files
authored
refactor: simplify source generator tests assertions (#710)
This pull request refactors the test assertions in several test files to improve clarity and maintainability. The main change is to separate the checks for the presence of generated source files from the assertions about their contents, making the tests more explicit and easier to read. Also moved some comments to the `.Because` reason of the corresponding assertions to include them in a generated failure message.
1 parent 80e0f24 commit b5c0562

16 files changed

Lines changed: 398 additions & 256 deletions

Tests/Mockolate.SourceGenerators.Tests/GeneralTests.cs

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -176,35 +176,50 @@ public interface IMyInterface<T>
176176
177177
""", typeof(IEnumerable<>));
178178

179-
await That(result.Sources).ContainsKey("Mock.IMyInterface_object.g.cs").WhoseValue
179+
await That(result.Sources).ContainsKey("Mock.IMyInterface_object.g.cs");
180+
await That(result.Sources["Mock.IMyInterface_object.g.cs"])
180181
.Contains("public global::System.Collections.Generic.IEnumerable<object> MyEnumerable");
181-
await That(result.Sources).ContainsKey("Mock.IMyInterface_bool.g.cs").WhoseValue
182+
await That(result.Sources).ContainsKey("Mock.IMyInterface_bool.g.cs");
183+
await That(result.Sources["Mock.IMyInterface_bool.g.cs"])
182184
.Contains("public global::System.Collections.Generic.IEnumerable<bool> MyEnumerable");
183-
await That(result.Sources).ContainsKey("Mock.IMyInterface_string.g.cs").WhoseValue
185+
await That(result.Sources).ContainsKey("Mock.IMyInterface_string.g.cs");
186+
await That(result.Sources["Mock.IMyInterface_string.g.cs"])
184187
.Contains("public global::System.Collections.Generic.IEnumerable<string> MyEnumerable");
185-
await That(result.Sources).ContainsKey("Mock.IMyInterface_char.g.cs").WhoseValue
188+
await That(result.Sources).ContainsKey("Mock.IMyInterface_char.g.cs");
189+
await That(result.Sources["Mock.IMyInterface_char.g.cs"])
186190
.Contains("public global::System.Collections.Generic.IEnumerable<char> MyEnumerable");
187-
await That(result.Sources).ContainsKey("Mock.IMyInterface_byte.g.cs").WhoseValue
191+
await That(result.Sources).ContainsKey("Mock.IMyInterface_byte.g.cs");
192+
await That(result.Sources["Mock.IMyInterface_byte.g.cs"])
188193
.Contains("public global::System.Collections.Generic.IEnumerable<byte> MyEnumerable");
189-
await That(result.Sources).ContainsKey("Mock.IMyInterface_sbyte.g.cs").WhoseValue
194+
await That(result.Sources).ContainsKey("Mock.IMyInterface_sbyte.g.cs");
195+
await That(result.Sources["Mock.IMyInterface_sbyte.g.cs"])
190196
.Contains("public global::System.Collections.Generic.IEnumerable<sbyte> MyEnumerable");
191-
await That(result.Sources).ContainsKey("Mock.IMyInterface_short.g.cs").WhoseValue
197+
await That(result.Sources).ContainsKey("Mock.IMyInterface_short.g.cs");
198+
await That(result.Sources["Mock.IMyInterface_short.g.cs"])
192199
.Contains("public global::System.Collections.Generic.IEnumerable<short> MyEnumerable");
193-
await That(result.Sources).ContainsKey("Mock.IMyInterface_ushort.g.cs").WhoseValue
200+
await That(result.Sources).ContainsKey("Mock.IMyInterface_ushort.g.cs");
201+
await That(result.Sources["Mock.IMyInterface_ushort.g.cs"])
194202
.Contains("public global::System.Collections.Generic.IEnumerable<ushort> MyEnumerable");
195-
await That(result.Sources).ContainsKey("Mock.IMyInterface_int.g.cs").WhoseValue
203+
await That(result.Sources).ContainsKey("Mock.IMyInterface_int.g.cs");
204+
await That(result.Sources["Mock.IMyInterface_int.g.cs"])
196205
.Contains("public global::System.Collections.Generic.IEnumerable<int> MyEnumerable");
197-
await That(result.Sources).ContainsKey("Mock.IMyInterface_uint.g.cs").WhoseValue
206+
await That(result.Sources).ContainsKey("Mock.IMyInterface_uint.g.cs");
207+
await That(result.Sources["Mock.IMyInterface_uint.g.cs"])
198208
.Contains("public global::System.Collections.Generic.IEnumerable<uint> MyEnumerable");
199-
await That(result.Sources).ContainsKey("Mock.IMyInterface_long.g.cs").WhoseValue
209+
await That(result.Sources).ContainsKey("Mock.IMyInterface_long.g.cs");
210+
await That(result.Sources["Mock.IMyInterface_long.g.cs"])
200211
.Contains("public global::System.Collections.Generic.IEnumerable<long> MyEnumerable");
201-
await That(result.Sources).ContainsKey("Mock.IMyInterface_ulong.g.cs").WhoseValue
212+
await That(result.Sources).ContainsKey("Mock.IMyInterface_ulong.g.cs");
213+
await That(result.Sources["Mock.IMyInterface_ulong.g.cs"])
202214
.Contains("public global::System.Collections.Generic.IEnumerable<ulong> MyEnumerable");
203-
await That(result.Sources).ContainsKey("Mock.IMyInterface_float.g.cs").WhoseValue
215+
await That(result.Sources).ContainsKey("Mock.IMyInterface_float.g.cs");
216+
await That(result.Sources["Mock.IMyInterface_float.g.cs"])
204217
.Contains("public global::System.Collections.Generic.IEnumerable<float> MyEnumerable");
205-
await That(result.Sources).ContainsKey("Mock.IMyInterface_double.g.cs").WhoseValue
218+
await That(result.Sources).ContainsKey("Mock.IMyInterface_double.g.cs");
219+
await That(result.Sources["Mock.IMyInterface_double.g.cs"])
206220
.Contains("public global::System.Collections.Generic.IEnumerable<double> MyEnumerable");
207-
await That(result.Sources).ContainsKey("Mock.IMyInterface_decimal.g.cs").WhoseValue
221+
await That(result.Sources).ContainsKey("Mock.IMyInterface_decimal.g.cs");
222+
await That(result.Sources["Mock.IMyInterface_decimal.g.cs"])
208223
.Contains("public global::System.Collections.Generic.IEnumerable<decimal> MyEnumerable");
209224
}
210225

@@ -229,7 +244,8 @@ public static void Main(string[] args)
229244
}
230245
""", typeof(HttpMessageHandler));
231246

232-
await That(result.Sources).ContainsKey("Mock.HttpMessageHandler.g.cs").WhoseValue
247+
await That(result.Sources).ContainsKey("Mock.HttpMessageHandler.g.cs");
248+
await That(result.Sources["Mock.HttpMessageHandler.g.cs"])
233249
.Contains("protected override void Dispose(bool disposing)").And
234250
.DoesNotContain("void Dispose()");
235251
}
@@ -255,7 +271,8 @@ public static void Main(string[] args)
255271
256272
""", typeof(IList<>));
257273

258-
await That(result.Sources).ContainsKey("Mock.IList_int.g.cs").WhoseValue
274+
await That(result.Sources).ContainsKey("Mock.IList_int.g.cs");
275+
await That(result.Sources["Mock.IList_int.g.cs"])
259276
.Contains("global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()").And
260277
.Contains("public global::System.Collections.Generic.IEnumerator<int> GetEnumerator()");
261278
}
@@ -286,7 +303,8 @@ public record MyRecord(int Id, string Name);
286303
287304
""", typeof(IList<>));
288305

289-
await That(result.Sources).ContainsKey("Mock.IList_MyRecord.g.cs").WhoseValue
306+
await That(result.Sources).ContainsKey("Mock.IList_MyRecord.g.cs");
307+
await That(result.Sources["Mock.IList_MyRecord.g.cs"])
290308
.Contains("""
291309
internal class IList_MyRecord :
292310
global::System.Collections.Generic.IList<global::MyOtherCode.MyRecord>
@@ -334,7 +352,8 @@ public interface IMyInterface
334352
335353
""", typeof(IEnumerable<>));
336354

337-
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs").WhoseValue
355+
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs");
356+
await That(result.Sources["Mock.IMyInterface.g.cs"])
338357
.Contains("public global::System.Collections.Generic.IEnumerable<object> EnumerableOfObject").And
339358
.Contains("public global::System.Collections.Generic.IEnumerable<bool> EnumerableOfBool").And
340359
.Contains("public global::System.Collections.Generic.IEnumerable<string> EnumerableOfString").And
@@ -458,8 +477,8 @@ public virtual int SomeMethod()
458477
459478
""", typeof(ObsoleteAttribute));
460479

461-
await That(result.Sources)
462-
.ContainsKey("Mock.MyBaseClass.g.cs").WhoseValue
480+
await That(result.Sources).ContainsKey("Mock.MyBaseClass.g.cs");
481+
await That(result.Sources["Mock.MyBaseClass.g.cs"])
463482
.Contains("""
464483
[global::System.Obsolete]
465484
public MyBaseClass(global::Mockolate.MockRegistry mockRegistry)
@@ -520,7 +539,8 @@ public interface IMyInterface2
520539

521540
await That(result.Diagnostics).IsEmpty();
522541

523-
await That(result.Sources).ContainsKey("Mock.IMyInterface1__IMyInterface2.g.cs").WhoseValue
542+
await That(result.Sources).ContainsKey("Mock.IMyInterface1__IMyInterface2.g.cs");
543+
await That(result.Sources["Mock.IMyInterface1__IMyInterface2.g.cs"])
524544
.Contains("public void MyMethod(int v1)").And
525545
.Contains("void global::MyCode.IMyInterface2.MyMethod(int v1)");
526546
}
@@ -558,7 +578,8 @@ public interface IMyInterface2
558578

559579
await That(result.Diagnostics).IsEmpty();
560580

561-
await That(result.Sources).ContainsKey("Mock.IMyInterface1.g.cs").WhoseValue
581+
await That(result.Sources).ContainsKey("Mock.IMyInterface1.g.cs");
582+
await That(result.Sources["Mock.IMyInterface1.g.cs"])
562583
.Contains("public void MyMethod(int v1)").And
563584
.Contains("void global::MyCode.IMyInterface2.MyMethod(int v1)");
564585
}
@@ -589,8 +610,8 @@ public class MyService
589610

590611
// A mock subclass declaring a property `MockRegistry` would hide the inherited field
591612
// (CS0108). The dedup pipeline must skip past the conflicting member name.
592-
await That(result.Sources)
593-
.ContainsKey("Mock.MyService.g.cs").WhoseValue
613+
await That(result.Sources).ContainsKey("Mock.MyService.g.cs");
614+
await That(result.Sources["Mock.MyService.g.cs"])
594615
.Contains("MockolateMockRegistry")
595616
.IgnoringNewlineStyle().And
596617
.DoesNotContain("private global::Mockolate.MockRegistry MockRegistry { get; }")
@@ -621,8 +642,8 @@ public class MockRegistry { }
621642
}
622643
""");
623644

624-
await That(result.Sources)
625-
.ContainsKey("Mock.MyService.g.cs").WhoseValue
645+
await That(result.Sources).ContainsKey("Mock.MyService.g.cs");
646+
await That(result.Sources["Mock.MyService.g.cs"])
626647
.Contains("MockolateMockRegistry")
627648
.IgnoringNewlineStyle().And
628649
.DoesNotContain("private global::Mockolate.MockRegistry MockRegistry { get; }")
@@ -654,8 +675,8 @@ public interface IMyInterface
654675

655676
// `Mock` is a method on the type, so the extension `Mock` property would shadow access.
656677
// CreateUniquePropertyName must now skip past it to a Mockolate_-prefixed alternative.
657-
await That(result.Sources)
658-
.ContainsKey("Mock.IMyInterface.g.cs").WhoseValue
678+
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs");
679+
await That(result.Sources["Mock.IMyInterface.g.cs"])
659680
.Contains("Mockolate_Mock")
660681
.IgnoringNewlineStyle();
661682
}
@@ -684,8 +705,8 @@ public interface IMyInterface
684705
}
685706
""");
686707

687-
await That(result.Sources)
688-
.ContainsKey("Mock.IMyInterface.g.cs").WhoseValue
708+
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs");
709+
await That(result.Sources["Mock.IMyInterface.g.cs"])
689710
.Contains("Mockolate_Mock__1")
690711
.IgnoringNewlineStyle();
691712
}
@@ -715,8 +736,8 @@ public interface IMyInterface
715736
}
716737
""");
717738

718-
await That(result.Sources)
719-
.ContainsKey("Mock.IMyInterface.g.cs").WhoseValue
739+
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs");
740+
await That(result.Sources["Mock.IMyInterface.g.cs"])
720741
.Contains("Mockolate_Mock__2")
721742
.IgnoringNewlineStyle();
722743
}
@@ -747,8 +768,8 @@ public interface IMyInterface
747768
}
748769
""", typeof(EventHandler));
749770

750-
await That(result.Sources)
751-
.ContainsKey("Mock.IMyInterface.g.cs").WhoseValue
771+
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs");
772+
await That(result.Sources["Mock.IMyInterface.g.cs"])
752773
.Contains("MockRegistry_2")
753774
.IgnoringNewlineStyle().And
754775
.DoesNotContain("private global::Mockolate.MockRegistry MockRegistry_1 { get; }")
@@ -880,7 +901,8 @@ public CustomAttribute(
880901
""", typeof(AllowNullAttribute), typeof(IDataParameter), typeof(LocalizableAttribute),
881902
typeof(AttributeUsageAttribute));
882903

883-
await That(result.Sources).ContainsKey("Mock.IMyService.g.cs").WhoseValue
904+
await That(result.Sources).ContainsKey("Mock.IMyService.g.cs");
905+
await That(result.Sources["Mock.IMyService.g.cs"])
884906
.Contains("""
885907
/// <inheritdoc cref="global::MyCode.IMyService.SomeProperty" />
886908
[global::System.Diagnostics.CodeAnalysis.AllowNull]

Tests/Mockolate.SourceGenerators.Tests/IndexerSetupsTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Threading;
1+
using System.Threading;
22

33
namespace Mockolate.SourceGenerators.Tests;
44

@@ -31,7 +31,8 @@ public interface IMyInterface
3131
}
3232
""", typeof(CancellationToken));
3333

34-
await That(result.Sources).ContainsKey("IndexerSetups.g.cs").WhoseValue
34+
await That(result.Sources).ContainsKey("IndexerSetups.g.cs");
35+
await That(result.Sources["IndexerSetups.g.cs"])
3536
.Contains(
3637
"internal class IndexerSetup<TValue, T1, T2, T3, T4, T5>(global::Mockolate.MockRegistry mockRegistry, global::Mockolate.Parameters.IParameterMatch<T1> parameter1, global::Mockolate.Parameters.IParameterMatch<T2> parameter2, global::Mockolate.Parameters.IParameterMatch<T3> parameter3, global::Mockolate.Parameters.IParameterMatch<T4> parameter4, global::Mockolate.Parameters.IParameterMatch<T5> parameter5) : global::Mockolate.Setup.IndexerSetup(mockRegistry)");
3738
}
@@ -96,7 +97,8 @@ public interface IMyInterface
9697
}
9798
""");
9899

99-
await That(result.Sources).ContainsKey("IndexerSetups.g.cs").WhoseValue
100+
await That(result.Sources).ContainsKey("IndexerSetups.g.cs");
101+
await That(result.Sources["IndexerSetups.g.cs"])
100102
.Contains("class IndexerSetup<TValue, T1, T2, T3, T4, T5, T6>(").And
101103
.DoesNotContain("class IndexerSetup<TValue, T1, T2, T3, T4, T5>(").And
102104
.DoesNotContain("class IndexerSetup<TValue, T1, T2, T3, T4, T5, T6, T7>(");

Tests/Mockolate.SourceGenerators.Tests/MethodSetupsTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Threading;
1+
using System.Threading;
22

33
namespace Mockolate.SourceGenerators.Tests;
44

@@ -34,7 +34,8 @@ public interface IMyInterface
3434
}
3535
""", typeof(DateTime), typeof(Task), typeof(CancellationToken));
3636

37-
await That(result.Sources).ContainsKey("MethodSetups.g.cs").WhoseValue
37+
await That(result.Sources).ContainsKey("MethodSetups.g.cs");
38+
await That(result.Sources["MethodSetups.g.cs"])
3839
.Contains(
3940
"internal abstract class ReturnMethodSetup<TReturn, T1, T2, T3, T4, T5> : global::Mockolate.Setup.MethodSetup")
4041
.And
@@ -182,7 +183,8 @@ public interface IMyInterface
182183
}
183184
""", typeof(DateTime), typeof(Task), typeof(CancellationToken));
184185

185-
await That(result.Sources).ContainsKey("MethodSetups.g.cs").WhoseValue
186+
await That(result.Sources).ContainsKey("MethodSetups.g.cs");
187+
await That(result.Sources["MethodSetups.g.cs"])
186188
.Contains("class ReturnMethodSetup<TReturn, T1, T2, T3, T4, T5, T6>").And
187189
.DoesNotContain("class VoidMethodSetup<T1, T2, T3, T4, T5, T6>").And
188190
.DoesNotContain("class ReturnMethodSetup<TReturn, T1, T2, T3, T4, T5>").And
@@ -216,7 +218,8 @@ public interface IMyInterface
216218
}
217219
""", typeof(DateTime), typeof(Task), typeof(CancellationToken));
218220

219-
await That(result.Sources).ContainsKey("MethodSetups.g.cs").WhoseValue
221+
await That(result.Sources).ContainsKey("MethodSetups.g.cs");
222+
await That(result.Sources["MethodSetups.g.cs"])
220223
.Contains("class VoidMethodSetup<T1, T2, T3, T4, T5, T6>").And
221224
.DoesNotContain("class ReturnMethodSetup<TReturn, T1, T2, T3, T4, T5, T6>").And
222225
.DoesNotContain("class VoidMethodSetup<T1, T2, T3, T4, T5>").And

Tests/Mockolate.SourceGenerators.Tests/MockBehaviorExtensionsTests.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22

33
namespace Mockolate.SourceGenerators.Tests;
44

@@ -31,15 +31,17 @@ public interface IMyInterface
3131
}
3232
""");
3333

34-
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs").WhoseValue
34+
await That(result.Sources).ContainsKey("Mock.IMyInterface.g.cs");
35+
await That(result.Sources["Mock.IMyInterface.g.cs"])
3536
.Contains("(b.DefaultValue.Generate(default(int)!), b.DefaultValue.Generate(default(string)!))").And
3637
.Contains(
3738
"(b.DefaultValue.Generate(default(int)!), b.DefaultValue.Generate(default(string)!), b.DefaultValue.Generate(default(int)!), b.DefaultValue.Generate(default(string)!), b.DefaultValue.Generate(default(int)!), b.DefaultValue.Generate(default(string)!), b.DefaultValue.Generate(default(int)!), b.DefaultValue.Generate(default(string)!))")
3839
.And
3940
.Contains(
4041
"(this.MockRegistry.Behavior.DefaultValue.Generate(default(int)!), this.MockRegistry.Behavior.DefaultValue.Generate(default(T1)!), this.MockRegistry.Behavior.DefaultValue.Generate(default(T2)!))");
4142

42-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
43+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
44+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
4345
.DoesNotContain("Generate<T1, T2>((T1, T2)").And
4446
.DoesNotContain("Generate<T1, T2, T3>((T1, T2, T3)").And
4547
.DoesNotContain("Generate<T1, T2, T3, T4, T5, T6, T7, T8>");
@@ -72,7 +74,8 @@ public interface IMyInterface
7274
}
7375
""");
7476

75-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
77+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
78+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
7679
.Contains("""
7780
public T[] Generate<T>(T[] nullValue, params object?[] parameters)
7881
=> global::System.Array.Empty<T>();
@@ -119,7 +122,8 @@ public interface IMyInterface
119122
}
120123
""", typeof(IEnumerable<>));
121124

122-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
125+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
126+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
123127
.Contains("""
124128
public global::System.Collections.Generic.IEnumerable<T> Generate<T>(global::System.Collections.Generic.IEnumerable<T> nullValue, params object?[] parameters)
125129
=> global::System.Array.Empty<T>();
@@ -158,7 +162,8 @@ public interface IMyInterface
158162
}
159163
""", typeof(Task));
160164

161-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
165+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
166+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
162167
.Contains("""
163168
public global::System.Threading.Tasks.Task<T> Generate<T>(global::System.Threading.Tasks.Task<T> nullValue, T value, params object?[] parameters)
164169
{
@@ -203,7 +208,8 @@ public interface IMyInterface
203208
}
204209
""", typeof(ValueTask));
205210

206-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
211+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
212+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
207213
.Contains("""
208214
public global::System.Threading.Tasks.ValueTask<T> Generate<T>(global::System.Threading.Tasks.ValueTask<T> nullValue, T value, params object?[] parameters)
209215
{

Tests/Mockolate.SourceGenerators.Tests/MockGenerator.AggregationTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ public interface IA { }
5656
public interface IB { }
5757
""");
5858

59-
await That(result.Sources).ContainsKey("Mock.AsExtensions.g.cs").WhoseValue
60-
// (IBase ↔ IB): bridge from a typed-as-IBase mock to IMockForIB.
61-
.Contains("internal static partial class MockExtensionsForIB").And
59+
await That(result.Sources).ContainsKey("Mock.AsExtensions.g.cs");
60+
await That(result.Sources["Mock.AsExtensions.g.cs"])
61+
.Contains("internal static partial class MockExtensionsForIB")
62+
.Because("the (IBase ↔ IB) bridge from a typed-as-IBase mock to IMockForIB must be emitted").And
6263
.Contains("extension(global::Mockolate.Mock.IMockForIBase mock)").And
63-
// (IA ↔ IB): bridge from a typed-as-IA mock to IMockForIB.
64-
.Contains("extension(global::Mockolate.Mock.IMockForIA mock)").And
65-
// Reverse direction is also emitted.
66-
.Contains("internal static partial class MockExtensionsForIBase").And
64+
.Contains("extension(global::Mockolate.Mock.IMockForIA mock)")
65+
.Because("the (IA ↔ IB) bridge from a typed-as-IA mock to IMockForIB must be emitted").And
66+
.Contains("internal static partial class MockExtensionsForIBase")
67+
.Because("the reverse direction must also be emitted").And
6768
.Contains("internal static partial class MockExtensionsForIA");
6869
}
6970

@@ -86,7 +87,8 @@ public static void Main(string[] args)
8687
}
8788
""", typeof(HttpClient));
8889

89-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
90+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
91+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
9092
.Contains("HttpResponseMessageFactory").And
9193
.Contains("new HttpResponseMessageFactory(global::System.Net.HttpStatusCode.NotImplemented)");
9294
}
@@ -114,7 +116,8 @@ public interface IService
114116
}
115117
""");
116118

117-
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs").WhoseValue
119+
await That(result.Sources).ContainsKey("MockBehaviorExtensions.g.cs");
120+
await That(result.Sources["MockBehaviorExtensions.g.cs"])
118121
.DoesNotContain("HttpResponseMessageFactory");
119122
}
120123

0 commit comments

Comments
 (0)