public void PopulateAddsItemsToCollectionFromExecuteStrategy()
        {
            var expected   = new Collection <Guid>();
            var buildChain = new BuildHistory();

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

            executeStrategy.BuildChain.Returns(buildChain);
            executeStrategy.Configuration.Returns(configuration);

            executeStrategy.Create(typeof(Guid)).Returns(Guid.NewGuid());

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

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

            actual.Should().BeSameAs(expected);

            var set = (Collection <Guid>)actual;

            set.Count.Should().BeGreaterOrEqualTo(sut.MinCount);
            set.Count.Should().BeLessOrEqualTo(sut.MaxCount);
            set.All(x => x != Guid.Empty).Should().BeTrue();
        }
        public void PopulateThrowsExceptionWithUnsupportedType()
        {
            var instance = new Lazy <bool>(() => true);

            var buildChain      = new BuildHistory();
            var executeStrategy = Substitute.For <IExecuteStrategy>();
            var configuration   = Substitute.For <IBuildConfiguration>();

            executeStrategy.Configuration.Returns(configuration);
            executeStrategy.BuildChain.Returns(buildChain);

            var sut = new EnumerableTypeCreator();

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

            action.Should().Throw <NotSupportedException>();
        }
        public void PopulateAddsItemsToInstancesTest(Type type)
        {
            var configuration = Model.UsingDefaultConfiguration();

            var sut = new EnumerableTypeCreator();

            var executeStrategy = new DefaultExecuteStrategy();

            executeStrategy.Initialize(configuration);

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

            sut.Populate(executeStrategy, actual);

            var converted = (IEnumerable)actual;

            converted.Should().NotBeEmpty();
        }
        public void PopulateThrowsExceptionWithUnsupportedTypeTest()
        {
            var instance = new Lazy<bool>(() => true);

            var strategy = Substitute.For<IExecuteStrategy>();

            var target = new EnumerableTypeCreator();

            Action action = () => target.Populate(instance, strategy);

            action.ShouldThrow<NotSupportedException>();
        }
        public void PopulateThrowsExceptionWithNullStrategyTest()
        {
            var instance = new List<string>();

            var target = new EnumerableTypeCreator();

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

            action.ShouldThrow<ArgumentNullException>();
        }
        public void PopulateThrowsExceptionWithNullInstanceTest()
        {
            var strategy = Substitute.For<IExecuteStrategy>();

            var target = new EnumerableTypeCreator();

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

            action.ShouldThrow<ArgumentNullException>();
        }
        public void PopulateAddsItemsToListFromExecuteStrategyTest()
        {
            var expected = new List<Guid>();

            var strategy = Substitute.For<IExecuteStrategy>();

            strategy.CreateWith(typeof(Guid)).Returns(Guid.NewGuid());

            var target = new EnumerableTypeCreator
            {
                AutoPopulateCount = 15
            };

            var actual = target.Populate(expected, strategy);

            actual.Should().BeSameAs(expected);

            var set = (List<Guid>) actual;

            set.Should().HaveCount(target.AutoPopulateCount);
            set.All(x => x != Guid.Empty).Should().BeTrue();
        }
        public void PopulateAddsItemsToInstancesTest(Type type)
        {
            var configuration = Model.BuildStrategy;
            var buildLog = configuration.GetBuildLog();

            var target = new EnumerableTypeCreator();
            var executeStrategy = new DefaultExecuteStrategy();

            executeStrategy.Initialize(configuration, buildLog);

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

            target.Populate(actual, executeStrategy);

            var converted = (IEnumerable) actual;

            converted.Should().NotBeEmpty();
        }