Ejemplo n.º 1
0
        public void CreateTypeThrowsExceptionWithNullType()
        {
            var executeStrategy = Substitute.For <IExecuteStrategy>();
            var valueGenerator  = Substitute.For <IValueGenerator>();

            var sut = new BuildCapability(valueGenerator);

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

            action.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 2
0
        public void CreateTypeReturnsValueFromValueGenerator()
        {
            var type  = typeof(string);
            var value = Guid.NewGuid().ToString();

            var executeStrategy = Substitute.For <IExecuteStrategy>();
            var valueGenerator  = Substitute.For <IValueGenerator>();

            valueGenerator.Generate(executeStrategy, type).Returns(value);

            var sut = new BuildCapability(valueGenerator);

            var actual = sut.CreateType(executeStrategy, type, null);

            actual.Should().Be(value);
        }
Ejemplo n.º 3
0
        public void CreateTypeReturnsValueFromCreationRule()
        {
            var type  = typeof(string);
            var value = Guid.NewGuid().ToString();

            var executeStrategy = Substitute.For <IExecuteStrategy>();
            var creationRule    = Substitute.For <ICreationRule>();

            creationRule.Create(executeStrategy, type).Returns(value);

            var sut = new BuildCapability(creationRule);

            var actual = sut.CreateType(executeStrategy, type, null);

            actual.Should().Be(value);
        }
Ejemplo n.º 4
0
        public void CreateTypeReturnsValueFromTypeCreator()
        {
            var type  = typeof(string);
            var value = Guid.NewGuid().ToString();
            var args  = new object?[]
            {
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
            };

            var executeStrategy = Substitute.For <IExecuteStrategy>();
            var typeCreator     = Substitute.For <ITypeCreator>();

            typeCreator.Create(executeStrategy, type, args).Returns(value);

            var sut = new BuildCapability(typeCreator, true, false);

            var actual = sut.CreateType(executeStrategy, type, args);

            actual.Should().Be(value);
        }