public void SubstituteConstructorReturnsValueSpecifiedInConstructorToEnableTestingOfCustomizations()
 {
     // Fixture setup
     var substituteConstructor = Substitute.For<ISpecimenBuilder>();
     // Exercise system
     var sut = new SubstituteRequestHandler(substituteConstructor);
     // Verify outcome
     Assert.Same(substituteConstructor, sut.SubstituteFactory);
     // Teardown
 }
Ejemplo n.º 2
0
        public void SubstituteConstructorReturnsValueSpecifiedInConstructorToEnableTestingOfCustomizations()
        {
            // Arrange
            var substituteConstructor = Substitute.For <ISpecimenBuilder>();
            // Act
            var sut = new SubstituteRequestHandler(substituteConstructor);

            // Assert
            Assert.Same(substituteConstructor, sut.SubstituteFactory);
        }
Ejemplo n.º 3
0
        public void SubstituteConstructorReturnsValueSpecifiedInConstructorToEnableTestingOfCustomizations()
        {
            // Fixture setup
            var substituteConstructor = Substitute.For <ISpecimenBuilder>();
            // Exercise system
            var sut = new SubstituteRequestHandler(substituteConstructor);

            // Verify outcome
            Assert.Same(substituteConstructor, sut.SubstituteFactory);
            // Teardown
        }
 public void CreateReturnsNoSpecimenWhenRequestIsNotAnExplicitSubstituteRequest()
 {
     // Fixture setup
     var constructor = Substitute.For<ISpecimenBuilder>();
     var sut = new SubstituteRequestHandler(constructor);
     var request = typeof(IComparable);
     var context = Substitute.For<ISpecimenContext>();
     // Exercise system
     object result = sut.Create(request, context);
     // Verify outcome
     var expected = new NoSpecimen(request);
     Assert.Equal(expected, result);
     // Teardown
 }
Ejemplo n.º 5
0
        public void CreateReturnsNoSpecimenWhenRequestIsNotAnExplicitSubstituteRequest()
        {
            // Arrange
            var constructor = Substitute.For <ISpecimenBuilder>();
            var sut         = new SubstituteRequestHandler(constructor);
            var request     = typeof(IComparable);
            var context     = Substitute.For <ISpecimenContext>();
            // Act
            object result = sut.Create(request, context);
            // Assert
            var expected = new NoSpecimen();

            Assert.Equal(expected, result);
        }
Ejemplo n.º 6
0
        public void CreateReturnsNoSpecimenWhenRequestIsNotAnExplicitSubstituteRequest()
        {
            // Fixture setup
            var constructor = Substitute.For <ISpecimenBuilder>();
            var sut         = new SubstituteRequestHandler(constructor);
            var request     = typeof(IComparable);
            var context     = Substitute.For <ISpecimenContext>();
            // Exercise system
            object result = sut.Create(request, context);
            // Verify outcome
            var expected = new NoSpecimen(request);

            Assert.Equal(expected, result);
            // Teardown
        }
 public void CreatePassesRequestedSubstituteTypeAndSpecimenContextToSubstituteConstructorAndReturnsInstanceItCreates()
 {
     // Fixture setup
     var context = Substitute.For<ISpecimenContext>();
     Type targetType = typeof(IComparable);
     var constructedSubstute = Substitute.For(new[] { targetType}, new object[0]);
     var constructor = Substitute.For<ISpecimenBuilder>();
     constructor.Create(targetType, context).Returns(constructedSubstute);
     var sut = new SubstituteRequestHandler(constructor);
     var request = new SubstituteRequest(targetType);
     // Exercise system
     object result = sut.Create(request, context);
     // Verify outcome
     Assert.Same(constructedSubstute, result);
     // Teardown
 }
        public void CustomizeInsertsProperlyConfiguredSubstituteRequestHandlerInCustomizationsToHandleSubstituteRequests()
        {
            // Arrange
            var sut = new AutoNSubstituteCustomization();
            SubstituteRequestHandler builder = null;
            var fixture = Substitute.For <IFixture>();

            fixture.Customizations.Insert(Arg.Any <int>(), Arg.Do <SubstituteRequestHandler>(b => builder = b));
            // Act
            sut.Customize(fixture);
            // Assert
            Assert.NotNull(builder);
            var substituteConstructor = Assert.IsType <MethodInvoker>(builder.SubstituteFactory);

            Assert.IsType <NSubstituteMethodQuery>(substituteConstructor.Query);
        }
Ejemplo n.º 9
0
        public void CreatePassesRequestedSubstituteTypeAndSpecimenContextToSubstituteConstructorAndReturnsInstanceItCreates()
        {
            // Arrange
            var  context             = Substitute.For <ISpecimenContext>();
            Type targetType          = typeof(IComparable);
            var  constructedSubstute = Substitute.For(new[] { targetType }, new object[0]);
            var  constructor         = Substitute.For <ISpecimenBuilder>();

            constructor.Create(targetType, context).Returns(constructedSubstute);
            var sut     = new SubstituteRequestHandler(constructor);
            var request = new SubstituteRequest(targetType);
            // Act
            object result = sut.Create(request, context);

            // Assert
            Assert.Same(constructedSubstute, result);
        }