public void CreateThrowExceptionWhenTypeNotEnumerable() { var executeStrategy = Substitute.For <IExecuteStrategy>(); var configuration = Substitute.For <IBuildConfiguration>(); executeStrategy.Configuration.Returns(configuration); var sut = new EnumerableTypeCreator(); Action action = () => sut.Create(executeStrategy, typeof(ICantCreate)); action.Should().Throw <BuildException>(); }
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 CreateReturnsInstanceOfMostAppropriateTypeTest(Type requestedType, Type expectedType) { var buildChain = new BuildHistory(); var executeStrategy = Substitute.For <IExecuteStrategy>(); var configuration = Substitute.For <IBuildConfiguration>(); executeStrategy.BuildChain.Returns(buildChain); executeStrategy.Configuration.Returns(configuration); var sut = new EnumerableTypeCreator(); var actual = sut.Create(executeStrategy, requestedType); actual.Should().NotBeNull(); actual.Should().BeOfType(expectedType); actual.Should().BeAssignableTo(requestedType); actual.As <IEnumerable>().Should().BeEmpty(); }
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(); }
public void CreateValidatesWhetherTypeIsSupportedTest(Type type, bool supported) { var target = new EnumerableTypeCreator(); Action action = () => target.Create(type, null, null); if (supported) { action.ShouldNotThrow(); } else { action.ShouldThrow<NotSupportedException>(); } }
public void CreateThrowsExceptionWithNullTypeTest() { var target = new EnumerableTypeCreator(); Action action = () => target.Create(null, null, null); action.ShouldThrow<ArgumentNullException>(); }
public void CreateReturnsNewListOfSpecfiedTypeTest(Type targetType) { var target = new EnumerableTypeCreator(); var actual = target.Create(targetType, null, null); actual.Should().BeOfType<List<int>>(); actual.As<List<int>>().Should().BeEmpty(); }
public void CreateReturnsInstanceTest(Type type) { var target = new EnumerableTypeCreator(); var actual = target.Create(type, null, null); actual.Should().NotBeNull(); }