public void ShouldCreateNewInstanceCreateParameters( [Substitute] ISpecimenBuilder specimenBuilder) { var sut = new ConstructorArgumentsTracker(specimenBuilder, typeof(SimpleType).GetConstructors().Single()); sut.CreateNewInstance(); specimenBuilder.Received(1).Create(Arg.Is(typeof(int)), Arg.Any <ISpecimenContext>()); }
public void ShouldCreateNewInstanceCreateParameters( [Substitute]ISpecimenBuilder specimenBuilder) { var sut = new ConstructorArgumentsTracker(specimenBuilder, typeof(SimpleType).GetConstructors().Single()); sut.CreateNewInstance(); specimenBuilder.Received(1).Create(Arg.Is(typeof(int)), Arg.Any<ISpecimenContext>()); }
public void ShouldCreateInstanceWithTheSameCtorArgs( [Substitute] ISpecimenBuilder specimenBuilder) { var sut = new ConstructorArgumentsTracker(specimenBuilder, typeof(decimal).GetConstructor(new[] { typeof(double) })); var instance = sut.CreateNewInstance(); var newInstance = sut.CreateNewInstanceWithTheSameCtorArgsAsIn(instance); Assert.False(ReferenceEquals(instance, newInstance)); Assert.True(instance.Equals(newInstance)); }
public void ShouldCreateInstanceWithTheSameCtorArgs( [Substitute]ISpecimenBuilder specimenBuilder) { var sut = new ConstructorArgumentsTracker(specimenBuilder, typeof(decimal).GetConstructor(new[] { typeof(double) })); var instance = sut.CreateNewInstance(); var newInstance = sut.CreateNewInstanceWithTheSameCtorArgsAsIn(instance); Assert.False(ReferenceEquals(instance, newInstance)); Assert.True(instance.Equals(newInstance)); }
public void ShouldCreateAsManyDistinctInstancesAsCtorParameters( [Substitute] ISpecimenBuilder specimenBuilder) { specimenBuilder.Create(Arg.Any <object>(), Arg.Any <ISpecimenContext>()).Returns(1); var sut = new ConstructorArgumentsTracker(specimenBuilder, typeof(SimpleType).GetConstructors().Single()); var instance = sut.CreateNewInstance() as SimpleType; specimenBuilder.ClearReceivedCalls(); var instances = sut.CreateDistinctInstancesByChaningOneByOneCtorArgIn(instance).ToList(); specimenBuilder.Received(1).Create(Arg.Is(typeof(int)), Arg.Any <ISpecimenContext>()); Assert.Equal(1, instances.Count); }
public void ShouldCreateAsManyDistinctInstancesAsCtorParameters( [Substitute]ISpecimenBuilder specimenBuilder) { specimenBuilder.Create(Arg.Any<object>(), Arg.Any<ISpecimenContext>()).Returns(1); var sut = new ConstructorArgumentsTracker(specimenBuilder, typeof(SimpleType).GetConstructors().Single()); var instance = sut.CreateNewInstance() as SimpleType; specimenBuilder.ClearReceivedCalls(); var instances = sut.CreateDistinctInstancesByChaningOneByOneCtorArgIn(instance).ToList(); specimenBuilder.Received(1).Create(Arg.Is(typeof(int)), Arg.Any<ISpecimenContext>()); Assert.Equal(1, instances.Count); }