public static void MatchingCallsWithMatches( IFoo fake, IEnumerable<ICompletedFakeObjectCall> completedCalls, IEnumerable<ICompletedFakeObjectCall> matchedCalls) { "Given a Fake" .x(() => fake = A.Fake<IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod(); fake.AnotherMethod("houseboat"); }); "And I use the static Fake class to get the calls made on the Fake" .x(() => completedCalls = Fake.GetCalls(fake)); "When I use Matching to find calls to a method with a match" .x(() => matchedCalls = completedCalls.Matching<IFoo>(c => c.AnotherMethod("houseboat"))); "Then it finds the matching call" .x(() => matchedCalls.Select(c => c.Method.Name).Should().Equal("AnotherMethod")); }
public static void MatchingCallsWithMatches( IFoo fake, IEnumerable <ICompletedFakeObjectCall> completedCalls, IEnumerable <ICompletedFakeObjectCall> matchedCalls) { "Given a Fake" .x(() => fake = A.Fake <IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod(); fake.AnotherMethod("houseboat"); }); "And I use the static Fake class to get the calls made on the Fake" .x(() => completedCalls = Fake.GetCalls(fake)); "When I use Matching to find calls to a method with a match" .x(() => matchedCalls = completedCalls.Matching <IFoo>(c => c.AnotherMethod("houseboat"))); "Then it finds the matching call" .x(() => matchedCalls.Select(c => c.Method.Name).Should().Equal("AnotherMethod")); }
public static void ClearRecordedCalls(IFoo fake) { "Given a Fake" .x(() => fake = A.Fake <IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod(); fake.AnotherMethod("houseboat"); }); "When I clear the recorded calls" .x(() => Fake.ClearRecordedCalls(fake)); "Then the recorded call list is empty" .x(() => Fake.GetCalls(fake).Should().BeEmpty()); }
public static void NonGenericCallsSuccess( IFoo fake, IEnumerable <ICompletedFakeObjectCall> completedCalls) { "Given a Fake" .x(() => fake = A.Fake <IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod(); fake.AnotherMethod("houseboat"); }); "When I use the static Fake class to get the calls made on the Fake" .x(() => completedCalls = Fake.GetCalls(fake)); "Then the calls made to the Fake will be returned" .x(() => completedCalls.Select(call => call.Method.Name) .Should() .Equal("AMethod", "AnotherMethod", "AnotherMethod")); }
public static void MatchingCallsWithNoMatches( IFoo fake, IEnumerable <ICompletedFakeObjectCall> completedCalls, IEnumerable <ICompletedFakeObjectCall> matchedCalls) { "Given a Fake" .x(() => fake = A.Fake <IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod("houseboat"); }); "And I use the static Fake class to get the calls made on the Fake" .x(() => completedCalls = Fake.GetCalls(fake)); "When I use Matching to find calls to a method with no matches" .x(() => matchedCalls = completedCalls.Matching <IFoo>(c => c.AnotherMethod("hovercraft"))); "Then it finds no calls" .x(() => matchedCalls.Should().BeEmpty()); }
public static void MatchingCallsWithNoMatches( IFoo fake, IEnumerable<ICompletedFakeObjectCall> completedCalls, IEnumerable<ICompletedFakeObjectCall> matchedCalls) { "Given a Fake" .x(() => fake = A.Fake<IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod("houseboat"); }); "And I use the static Fake class to get the calls made on the Fake" .x(() => completedCalls = Fake.GetCalls(fake)); "When I use Matching to find calls to a method with no matches" .x(() => matchedCalls = completedCalls.Matching<IFoo>(c => c.AnotherMethod("hovercraft"))); "Then it finds no calls" .x(() => matchedCalls.Should().BeEmpty()); }
public static void CanEnumerateRulesWhileConfiguringFake( IFoo fake, FakeManager manager, IEnumerable <IFakeObjectCallRule> rules, IEnumerator <IFakeObjectCallRule> enumerator) { "Given a Fake" .x(() => fake = A.Fake <IFoo>()); "And I configure a method call on the Fake" .x(() => A.CallTo(() => fake.AMethod()).DoesNothing()); "And I configure another method call on the Fake" .x(() => A.CallTo(() => fake.AMethod()).DoesNothing()); "And I get the Fake's manager" .x(() => manager = Fake.GetFakeManager(fake)); "When I fetch the rules from the manager" .x(() => rules = manager.Rules); "And I get the rules' enumerator" .x(() => enumerator = rules.GetEnumerator()); "And I step over the first rule" .x(() => enumerator.MoveNext()); "And I configure the Fake with another rule" .x(() => A.CallTo(() => fake.AnotherMethod()).DoesNothing()); "And I step over the next rule" .x(() => enumerator.MoveNext()); "Then I come to the end of the list of rules" .x(() => enumerator.MoveNext().Should().BeFalse()); }
public static void NonGenericCallsSuccess( IFoo fake, IEnumerable<ICompletedFakeObjectCall> completedCalls) { "Given a Fake" .x(() => fake = A.Fake<IFoo>()); "And I make several calls to the Fake" .x(() => { fake.AMethod(); fake.AnotherMethod(); fake.AnotherMethod("houseboat"); }); "When I use the static Fake class to get the calls made on the Fake" .x(() => completedCalls = Fake.GetCalls(fake)); "Then the calls made to the Fake will be returned" .x(() => completedCalls.Select(call => call.Method.Name) .Should() .Equal("AMethod", "AnotherMethod", "AnotherMethod")); }