public void CreateThrowsExceptionWhenCreateVerificationFailsTest()
        {
            var buildChain = new LinkedList<object>();

            var target = new TypeCreatorWrapper();

            Action action = () => target.Create(typeof(bool), null, buildChain);

            action.ShouldThrow<NotSupportedException>();
        }
Exemple #2
0
        public void PopulateThrowsExceptionWithNullExecuteStrategy()
        {
            var person = new Person();

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Populate(null !, person);

            action.Should().Throw <ArgumentNullException>();
        }
        public void CreateDoesNotThrowsExceptionWhenCreateVerificationPassesTest()
        {
            var buildChain = new LinkedList<object>();

            var target = new TypeCreatorWrapper();

            Action action = () => target.Create(typeof(List<string>), null, buildChain);

            action.ShouldNotThrow();
        }
Exemple #4
0
        public void CanCreateThrowsExceptionWithNullType()
        {
            var configuration = Substitute.For <IBuildConfiguration>();

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.CanCreate(configuration, null !, (Type)null !);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #5
0
        public void CanPopulateThrowsExceptionWithNullProperty()
        {
            var configuration = Substitute.For <IBuildConfiguration>();
            var buildChain    = new BuildHistory();

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.CanPopulate(configuration, buildChain, (PropertyInfo)null !);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #6
0
        public void PopulateThrowsExceptionWithNullStrategyBuildChain()
        {
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns((IBuildChain)null !);

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Populate(executeStrategy, typeof(string));

            action.Should().Throw <InvalidOperationException>();
        }
Exemple #7
0
        public void PopulateThrowsExceptionWhenPopulateVerificationFails()
        {
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Populate(executeStrategy, false);

            action.Should().Throw <NotSupportedException>();
        }
Exemple #8
0
        public void CreateForTypeThrowsExceptionWithNullStrategy()
        {
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Create(null !, typeof(string));

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #9
0
        public void PopulateThrowsExceptionWithNullType()
        {
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Populate(executeStrategy, null !);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #10
0
        public void CreateForPropertyThrowsExceptionWithNullStrategy()
        {
            var property        = typeof(Person).GetProperty(nameof(Person.FirstName)) !;
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Create(null !, property);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #11
0
        public void PopulateDoesNotThrowsExceptionWhenPopulateVerificationPasses()
        {
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var value = new List <string>();

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Populate(executeStrategy, value);

            action.Should().NotThrow();
        }
Exemple #12
0
        public void CreateForParameterThrowsExceptionWithNullStrategy()
        {
            var parameterInfo = typeof(Person).GetConstructors()
                                .First(x => x.GetParameters().FirstOrDefault()?.Name == "firstName").GetParameters().First();
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new TypeCreatorWrapper();

            Action action = () => sut.Create(null !, parameterInfo);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #13
0
        public void PopulateReturnsProvidedInstance()
        {
            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            executeStrategy.BuildChain.Returns(buildChain);

            var expected = new List <string>();

            var sut = new TypeCreatorWrapper();

            var actual = sut.Populate(executeStrategy, expected);

            actual.Should().BeSameAs(expected);
        }
Exemple #14
0
        public void CreateReturnsValue()
        {
            var targetType = typeof(List <string>);

            var typeResolver    = Substitute.For <ITypeResolver>();
            var configuration   = Substitute.For <IBuildConfiguration>();
            var executeStrategy = Substitute.For <IExecuteStrategy>();

            configuration.TypeResolver.Returns(typeResolver);
            typeResolver.GetBuildType(configuration, targetType).Returns(targetType);
            executeStrategy.Configuration.Returns(configuration);

            var sut = new TypeCreatorWrapper();

            var actual = sut.Create(executeStrategy, targetType);

            actual.Should().NotBeNull();
        }
        public void PopulateDoesNotThrowsExceptionWhenPopulateVerificationPassesTest()
        {
            var executeStrategy = new DummyExecuteStrategy();
            var value = new List<string>();

            var target = new TypeCreatorWrapper();

            Action action = () => target.Populate(value, executeStrategy);

            action.ShouldNotThrow();
        }
        public void PopulateThrowsExceptionWithNullExecuteStrategyTest()
        {
            var person = new Person();

            var target = new TypeCreatorWrapper();

            Action action = () => target.Populate(person, null);

            action.ShouldThrow<ArgumentNullException>();
        }
        public void PopulateThrowsExceptionWithNullInstanceTest()
        {
            var executeStrategy = new DummyExecuteStrategy();

            var target = new TypeCreatorWrapper();

            Action action = () => target.Populate(null, executeStrategy);

            action.ShouldThrow<ArgumentNullException>();
        }
        public void GeneratorReturnsInstanceTest()
        {
            var target = new TypeCreatorWrapper();

            target.Random.Should().NotBeNull();
        }
        public void PopulateThrowsExceptionWhenPopulateVerificationFailsTest()
        {
            var executeStrategy = new DummyExecuteStrategy();

            var target = new TypeCreatorWrapper();

            Action action = () => target.Populate(false, executeStrategy);

            action.ShouldThrow<NotSupportedException>();
        }
Exemple #20
0
        public void GeneratorReturnsInstance()
        {
            var sut = new TypeCreatorWrapper();

            sut.Random.Should().NotBeNull();
        }