public void WithoutGenerateDelegates_ShouldNotAddRelayForDelegates() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoNSubstituteCustomization { GenerateDelegates = false }; // Act sut.Customize(fixtureStub); // Assert Assert.DoesNotContain(fixtureStub.Customizations, c => c is SubstituteRelay); }
public void CustomizeInsertsProperlyConfiguredSubstituteRequestHandlerInCustomizationsToHandleSubstituteRequests() { // Arrange var sut = new AutoNSubstituteCustomization(); var fixtureStub = new FixtureStub(); // Act sut.Customize(fixtureStub); // Assert var substituteRequestHandler = fixtureStub.Customizations.OfType <SubstituteRequestHandler>().Single(); var substituteConstructor = Assert.IsType <MethodInvoker>(substituteRequestHandler.SubstituteFactory); Assert.IsType <NSubstituteMethodQuery>(substituteConstructor.Query); }
public void WithGenerateDelegates_CustomizeAddsRelayForDelegates() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoNSubstituteCustomization { GenerateDelegates = true }; // Act sut.Customize(fixtureStub); // Assert var substituteRelay = fixtureStub.Customizations.OfType <SubstituteRelay>().Single(); Assert.IsType <DelegateSpecification>(substituteRelay.Specification); }
public void WithConfigureMembers_CustomizeAddsPostprocessorWithSubstituteRequestHandlerAndCommandsToCustomizations() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoNSubstituteCustomization { ConfigureMembers = true }; // Act sut.Customize(fixtureStub); // Assert var postprocessor = fixtureStub.Customizations.OfType <Postprocessor>().Single(); var substituteRequestHandler = Assert.IsAssignableFrom <SubstituteRequestHandler>(postprocessor.Builder); var substituteFactory = Assert.IsType <MethodInvoker>(substituteRequestHandler.SubstituteFactory); Assert.IsType <NSubstituteMethodQuery>(substituteFactory.Query); var compositeCommand = Assert.IsAssignableFrom <CompositeSpecimenCommand>(postprocessor.Command); Assert.True(compositeCommand.Commands.OfType <NSubstituteRegisterCallHandlerCommand>().Any()); Assert.True(compositeCommand.Commands.OfType <NSubstituteSealedPropertiesCommand>().Any()); }