public static void CallbackOnStringReturningMethod( IFoo fake, bool wasCalled, string result) { "Given a fake" .x(() => fake = A.Fake <IFoo>()); "And I configure a method to invoke an action when a string-returning method is called" .x(() => A.CallTo(() => fake.Bas()).Invokes(x => wasCalled = true)); "When I call the method" .x(() => result = fake.Bas()); "Then it invokes the action" .x(() => wasCalled.Should().BeTrue()); "And a default value is returned" .x(() => result.Should().BeEmpty()); }
public static void InvokesAfterStrictNonFakeableReferenceTypeKeepsDefaultReturnValue( IFoo fake, string result) { "Given a strict fake" .x(() => fake = A.Fake <IFoo>(options => options.Strict())); "And I configure all methods to invoke an action" .x(() => A.CallTo(fake).Invokes(() => { })); "When I call a non-fakeable reference type method" .x(() => result = fake.Bas()); "Then it returns the same value as an unconfigured fake" .x(() => result.Should().Be(A.Fake <IFoo>().Bas())); }
public static void InvokesAfterStrictReferenceType( IFoo fake, string result) { "Given a strict fake" .x(() => fake = A.Fake <IFoo>(options => options.Strict())); "And I configure all methods to invoke an action" .x(() => A.CallTo(fake).Invokes(() => { })); "When I call a reference type method" .x(() => result = fake.Bas()); "Then it returns null" .x(() => result.Should().BeNull()); }
public static void InvokesAfterStrictReferenceType( IFoo fake, string result) { "Given a strict fake" .x(() => fake = A.Fake<IFoo>(options => options.Strict())); "And I configure all methods to invoke an action" .x(() => A.CallTo(fake).Invokes(() => { })); "When I call a reference type method" .x(() => result = fake.Bas()); "Then it returns null" .x(() => result.Should().BeNull()); }