public static IFixture GetDefaultFixture() { var autoMoqCustomization = new AutoMoqCustomization(); return(new Fixture() .Customize(autoMoqCustomization)); }
public void SutIsCustomization() { // Fixture setup // Exercise system var sut = new AutoMoqCustomization(); // Verify outcome Assert.IsAssignableFrom<ICustomization>(sut); // Teardown }
public void GenerateDelegatesIsDisabledByDefault() { // Arrange // Act var sut = new AutoMoqCustomization(); // Assert Assert.False(sut.GenerateDelegates); }
public void CustomizeNullFixtureThrows() { // Fixture setup var sut = new AutoMoqCustomization(); // Exercise system and verify outcome Assert.Throws<ArgumentNullException>(() => sut.Customize(null)); // Teardown }
public void ThrowsIfNullRelayIsSet() { // Arrange var sut = new AutoMoqCustomization(); // Act & Assert Assert.Throws <ArgumentNullException>(() => sut.Relay = null); }
public void CustomizeNullFixtureThrows() { // Arrange var sut = new AutoMoqCustomization(); // Act & Assert Assert.Throws <ArgumentNullException>(() => sut.Customize(null)); }
public void SutIsCustomization() { // Arrange // Act var sut = new AutoMoqCustomization(); // Assert Assert.IsAssignableFrom <ICustomization>(sut); }
public void ConfigureMembersIsDisabledByDefault() { // Arrange // Act var sut = new AutoMoqCustomization(); // Assert Assert.False(sut.ConfigureMembers); }
public void SpecificationIsNotNullWhenInitializedWithDefaultConstructor() { // Arrange var sut = new AutoMoqCustomization(); // Act var result = sut.Relay; // Assert Assert.IsType <MockRelay>(result); }
public void SutIsCustomization() { // Fixture setup // Exercise system var sut = new AutoMoqCustomization(); // Verify outcome Assert.IsAssignableFrom <ICustomization>(sut); // Teardown }
public void CustomizeNullFixtureThrows() { // Fixture setup var sut = new AutoMoqCustomization(); // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.Customize(null)); // Teardown }
public void SpecificationIsNotNullWhenInitializedWithDefaultConstructor() { // Fixture setup var sut = new AutoMoqCustomization(); // Exercise system var result = sut.Relay; // Verify outcome Assert.IsType<MockRelay>(result); // Teardown }
public void ShouldPreserveTheSetRelay() { // Arrange var sut = new AutoMoqCustomization(); var relay = new CompositeSpecimenBuilder(); // Act sut.Relay = relay; // Assert Assert.Equal(relay, sut.Relay); }
public void SpecificationIsCorrectWhenInitializedWithRelay() { // Arrange var expectedRelay = new MockRelay(); var sut = new AutoMoqCustomization(expectedRelay); // Act ISpecimenBuilder result = sut.Relay; // Assert Assert.Equal(expectedRelay, result); }
public void SpecificationIsNotNullWhenInitializedWithDefaultConstructor() { // Fixture setup var sut = new AutoMoqCustomization(); // Exercise system var result = sut.Relay; // Verify outcome Assert.IsType <MockRelay>(result); // Teardown }
public void SpecificationIsCorrectWhenInitializedWithRelay() { // Fixture setup var expectedRelay = new MockRelay(); var sut = new AutoMoqCustomization(expectedRelay); // Exercise system ISpecimenBuilder result = sut.Relay; // Verify outcome Assert.Equal(expectedRelay, result); // Teardown }
public void SpecificationIsCorrectWhenInitializedWithRelay() { // Fixture setup var expectedRelay = new MockRelay(); var sut = new AutoMoqCustomization(expectedRelay); // Exercise system ISpecimenBuilder result = sut.Relay; // Verify outcome Assert.Equal(expectedRelay, result); // Teardown }
public void CustomizeAddsAppropriateResidueCollector() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoMoqCustomization(); // Act sut.Customize(fixtureStub); // Assert Assert.Contains(sut.Relay, fixtureStub.ResidueCollectors); }
public void WithConfigureMembers_CustomizeAddsPostprocessorToCustomizations() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoMoqCustomization { ConfigureMembers = true }; // Act sut.Customize(fixtureStub); // Assert Assert.Contains(fixtureStub.Customizations, builder => builder is Postprocessor); }
public void WithoutGenerateDelegates_DoesNotAddMockRelayForDelegate() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoMoqCustomization { GenerateDelegates = false }; // Act sut.Customize(fixtureStub); // Assert Assert.DoesNotContain(fixtureStub.Customizations, c => c is MockRelay); }
public static IFixture GetDefaultFixture() { var userRepositoryFactory = new UserRepositoryFactory(); var loggerFactory = new LoggerFactory(); var autoMoqCustomization = new AutoMoqCustomization(); IFixture fixture = new Fixture(); fixture.Customizations.Add(userRepositoryFactory); fixture.Customizations.Add(loggerFactory); fixture.Customize(autoMoqCustomization); return(fixture); }
public void CustomizeAddsAppropriateResidueCollector() { // Fixture setup var residueCollectors = new List<ISpecimenBuilder>(); var fixtureStub = new Mock<IFixture> { DefaultValue = DefaultValue.Mock }; fixtureStub.SetupGet(c => c.ResidueCollectors).Returns(residueCollectors); var sut = new AutoMoqCustomization(); // Exercise system sut.Customize(fixtureStub.Object); // Verify outcome Assert.Contains(sut.Relay, residueCollectors); // Teardown }
public void CustomizeAddsAppropriateCustomizations() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoMoqCustomization(); // Act sut.Customize(fixtureStub); // Assert var postprocessor = fixtureStub.Customizations.OfType <MockPostprocessor>().Single(); var ctorInvoker = Assert.IsAssignableFrom <MethodInvoker>(postprocessor.Builder); Assert.IsAssignableFrom <MockConstructorQuery>(ctorInvoker.Query); }
public void WithGenerateDelegates_CustomizeAddsRelay() { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoMoqCustomization { GenerateDelegates = true }; // Act sut.Customize(fixtureStub); // Assert var mockRelay = (MockRelay)fixtureStub.Customizations.Single(c => c is MockRelay); Assert.IsType <DelegateSpecification>(mockRelay.MockableSpecification); }
public void WithConfigureMembers_CustomizeAddsMockCommandsToPostprocessor(Type expectedCommandType) { // Arrange var fixtureStub = new FixtureStub(); var sut = new AutoMoqCustomization { ConfigureMembers = true }; // Act sut.Customize(fixtureStub); // Assert var postprocessor = (Postprocessor)fixtureStub.Customizations.Single(builder => builder is Postprocessor); var compositeCommand = (CompositeSpecimenCommand)postprocessor.Command; Assert.Contains(compositeCommand.Commands, command => command.GetType() == expectedCommandType); }
public void CustomizeAddsAppropriateResidueCollector() { // Arrange var residueCollectors = new List <ISpecimenBuilder>(); var fixtureStub = new Mock <IFixture> { DefaultValue = DefaultValue.Mock }; fixtureStub.SetupGet(c => c.ResidueCollectors).Returns(residueCollectors); var sut = new AutoMoqCustomization(); // Act sut.Customize(fixtureStub.Object); // Assert Assert.Contains(sut.Relay, residueCollectors); }
public void CustomizeAddsAppropriateResidueCollector() { // Fixture setup var residueCollectors = new List <ISpecimenBuilder>(); var fixtureStub = new Mock <IFixture> { DefaultValue = DefaultValue.Mock }; fixtureStub.SetupGet(c => c.ResidueCollectors).Returns(residueCollectors); var sut = new AutoMoqCustomization(); // Exercise system sut.Customize(fixtureStub.Object); // Verify outcome Assert.Contains(sut.Relay, residueCollectors); // Teardown }
public void CustomizeAddsAppropriateCustomizations() { // Arrange var customizations = new List <ISpecimenBuilder>(); var fixtureStub = new Mock <IFixture> { DefaultValue = DefaultValue.Mock }; fixtureStub.SetupGet(c => c.Customizations).Returns(customizations); var sut = new AutoMoqCustomization(); // Act sut.Customize(fixtureStub.Object); // Assert var postprocessor = customizations.OfType <MockPostprocessor>().Single(); var ctorInvoker = Assert.IsAssignableFrom <MethodInvoker>(postprocessor.Builder); Assert.IsAssignableFrom <MockConstructorQuery>(ctorInvoker.Query); }
public CustomAuthenticationHandlerTests() { var fixtureCustomizations = new AutoMoqCustomization { ConfigureMembers = true }; _fixture = new Fixture().Customize(fixtureCustomizations); AllowFixtureCircularDependencies(); _vesoAuthServiceMock = _fixture.Freeze <Mock <IAuthService> >(); _optionsMonitorMock = _fixture.Freeze <Mock <IOptionsMonitor <AuthenticationSchemeOptions> > >(); _clockMock = _fixture.Freeze <Mock <ISystemClock> >(); _serviceProviderMock = _fixture.Freeze <Mock <IServiceProvider> >(); _authenticationServiceMock = _fixture.Freeze <Mock <IAuthenticationService> >(); _fixture.Register <ILoggerFactory>(() => new NullLoggerFactory()); _urlEncoder = UrlEncoder.Default; _serviceProviderMock.Setup(s => s.GetService(typeof(IAuthenticationService))) .Returns(_authenticationServiceMock.Object); _optionsMonitorMock.Setup(o => o.Get(It.IsAny <string>())) .Returns(new AuthenticationSchemeOptions { ForwardAuthenticate = null }); _context = new DefaultHttpContext { RequestServices = _serviceProviderMock.Object }; _scheme = new AuthenticationScheme( _fixture.Create <string>(), null, typeof(CustomAuthenticationHandler)); _sut = _fixture.Create <CustomAuthenticationHandler>(); _sut.InitializeAsync(_scheme, _context).Wait(); }
public void CustomizeAddsAppropriateCustomizations() { // Fixture setup var customizations = new List<ISpecimenBuilder>(); var fixtureStub = new Mock<IFixture> { DefaultValue = DefaultValue.Mock }; fixtureStub.SetupGet(c => c.Customizations).Returns(customizations); var sut = new AutoMoqCustomization(); // Exercise system sut.Customize(fixtureStub.Object); // Verify outcome var postprocessor = customizations.OfType<MockPostprocessor>().Single(); var ctorInvoker = Assert.IsAssignableFrom<MethodInvoker>(postprocessor.Builder); Assert.IsAssignableFrom<MockConstructorQuery>(ctorInvoker.Query); // Teardown }