public void IgnoresNonMockSpecimens() { // Fixture setup // The context mock has a strict behaviour - if any of its members are invoked, an exception will be thrown var context = new Mock <ISpecimenContext>(MockBehavior.Strict); var specimen = new TypeWithVirtualMembers(); var sut = new MockVirtualMethodsCommand(); // Exercise system and verify outcome Assert.DoesNotThrow(() => sut.Execute(specimen, context.Object)); }
public void IgnoresNonMockSpecimens() { // Arrange // The context mock has a strict behaviour - if any of its members are invoked, an exception will be thrown var context = new Mock <ISpecimenContext>(MockBehavior.Strict); var specimen = new TypeWithVirtualMembers(); var sut = new MockVirtualMethodsCommand(); // Act & Assert Assert.Null(Record.Exception(() => sut.Execute(specimen, context.Object))); }
public void WithConfigureMembers_VirtualMemberConfiguredToCallBaseMethodReturnsValueFromBaseMethod() { // Arrange var expectedValue = new TypeWithVirtualMembers().VirtualMethod(); var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); var result = fixture.Create <Fake <TypeWithVirtualMembers> >(); A.CallTo(() => result.FakedObject.VirtualMethod()).CallsBaseMethod(); // Act // Assert var virtualMethodReturnValue = result.FakedObject.VirtualMethod(); Assert.Equal(expectedValue, virtualMethodReturnValue); }