public void CreateValidatesWhetherTypeIsSupportedTest(Type type, bool supported)
        {
            var buildChain = new BuildHistory();

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

            configuration.TypeResolver.Returns(typeResolver);
            typeResolver.GetBuildType(configuration, Arg.Any <Type>()).Returns(x => x.Arg <Type>());
            executeStrategy.BuildChain.Returns(buildChain);
            executeStrategy.Configuration.Returns(configuration);

            var sut = new ArrayTypeCreator();

            Action action = () => sut.Create(executeStrategy, type);

            if (supported)
            {
                action.Should().NotThrow();
            }
            else
            {
                action.Should().Throw <NotSupportedException>();
            }
        }
        public void CreateReturnsInstanceTest(Type type)
        {
            var buildChain = new BuildHistory();

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

            configuration.TypeResolver.Returns(typeResolver);
            typeResolver.GetBuildType(configuration, Arg.Any <Type>()).Returns(x => x.Arg <Type>());
            executeStrategy.BuildChain.Returns(buildChain);
            executeStrategy.Configuration.Returns(configuration);

            var sut = new ArrayTypeCreator();

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

            actual.Should().NotBeNull();
        }
        public void CreateReturnsBetweenMinAndMaxCountItems()
        {
            var buildChain = new BuildHistory();

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

            configuration.TypeResolver.Returns(typeResolver);
            typeResolver.GetBuildType(configuration, Arg.Any <Type>()).Returns(x => x.Arg <Type>());
            executeStrategy.BuildChain.Returns(buildChain);
            executeStrategy.Configuration.Returns(configuration);

            var sut = new ArrayTypeCreator
            {
                MinCount = 5,
                MaxCount = 15
            };

            var actual = (Person[])sut.Create(executeStrategy, typeof(Person[])) !;

            actual.Length.Should().BeGreaterOrEqualTo(sut.MinCount);
            actual.Length.Should().BeLessOrEqualTo(sut.MaxCount);
        }
        public void CreateValidatesWhetherTypeIsSupportedTest(Type type, bool supported)
        {
            var target = new ArrayTypeCreator();

            Action action = () => target.Create(type, null, null);

            if (supported)
            {
                action.ShouldNotThrow();
            }
            else
            {
                action.ShouldThrow<NotSupportedException>();
            }
        }
        public void CreateThrowsExceptionWithNullTypeTest()
        {
            var target = new ArrayTypeCreator();

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

            action.ShouldThrow<ArgumentNullException>();
        }
        public void CreateReturnsInstanceTest(Type type)
        {
            var target = new ArrayTypeCreator();

            var actual = target.Create(type, null, null);

            actual.Should().NotBeNull();
        }