Пример #1
0
        public void CanProcess_NestedTypeValidMember()
        {
            //Arrange
            var value   = new NestedType();
            var target  = new ObjectTextSubstitutionRule <NestedType>(value);
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue.StringValue");

            //Act
            var actual = target.CanProcess(context);

            //Assert
            actual.Should().BeTrue();
        }
Пример #2
0
        public void CanProcess_NestedTypeNoSuchMember()
        {
            //Arrange
            var value   = new SimpleType();
            var target  = new ObjectTextSubstitutionRule <SimpleType>(value);
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue.NonValue");

            //Act
            var actual = target.CanProcess(context);

            //Assert
            actual.Should().BeFalse();
        }
Пример #3
0
        public void Process_ComplexTypeWithNullReferenceMemberReturnsEmptyString()
        {
            //Arrange
            var value   = new NestedType();
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue");
            var target  = new ObjectTextSubstitutionRule <NestedType>(value);

            //Act
            var actual = target.Process(context);

            //Assert
            actual.Should().BeEmpty();
        }
Пример #4
0
        public void CanProcess_SimpleTypeWithField()
        {
            //Arrange
            var value   = new SimpleType();
            var target  = new ObjectTextSubstitutionRule <SimpleType>(value);
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "DoubleField");

            //Act
            var actual = target.CanProcess(context);

            //Assert
            actual.Should().BeTrue();
        }
Пример #5
0
        public void Process_UsingSimpleTypeWithBadMember()
        {
            //Arrange
            var value   = new SimpleType();
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "BogusValue");
            var target  = new ObjectTextSubstitutionRule <SimpleType>(value);

            //Act
            var actual = target.Process(context);

            //Assert
            actual.Should().BeNull();
        }
Пример #6
0
        public void Process_ComplexTypeAsFinalValueCallsToString()
        {
            //Arrange
            var value = new NestedType()
            {
                SimpleValue = new SimpleType()
            };
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue");
            var target  = new ObjectTextSubstitutionRule <NestedType>(value);

            //Act
            var actual = target.Process(context);

            //Assert
            actual.Should().Be(SimpleType.SimpleTypeStringName);
        }
Пример #7
0
        public void Process_UsingSimpleTypeWithWrongCaseShouldWork()
        {
            //Arrange
            var value = new SimpleType()
            {
                Int32Value = 1, StringValue = "First"
            };
            var expected = "1";
            var context  = new TextSubstitutionContext(new TextSubstitutionOptions(), "int32VALUE");
            var target   = new ObjectTextSubstitutionRule <SimpleType>(value);

            //Act
            var actual = target.Process(context);

            //Assert
            actual.Should().Be(expected);
        }
Пример #8
0
        public void Process_UsingNestedTypeWithWrongCaseShouldWork()
        {
            //Arrange
            var expected = 2011;
            var value    = new NestedType()
            {
                SimpleValue = new SimpleType()
                {
                    StringValue = "second", Int32Value = 2
                },
                DateTimeValue = new DateTime(expected, 10, 25, 1, 2, 3)
            };
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "DateTimeValue.yEAR");
            var target  = new ObjectTextSubstitutionRule <NestedType>(value);

            //Act
            var actual = target.Process(context);

            //Assert
            actual.Should().Be(expected.ToString());
        }
Пример #9
0
        public void Process_UsingNestedType()
        {
            //Arrange
            var expected = "Second";
            var value    = new NestedType()
            {
                SimpleValue = new SimpleType()
                {
                    StringValue = expected, Int32Value = 2
                },
                DateTimeValue = new DateTime(2011, 10, 25, 1, 2, 3)
            };
            var context = new TextSubstitutionContext(new TextSubstitutionOptions(), "SimpleValue.StringValue");
            var target  = new ObjectTextSubstitutionRule <NestedType>(value);

            //Act
            var actual = target.Process(context);

            //Assert
            actual.Should().Be(expected);
        }