Beispiel #1
0
        public void When_value_is_defined_in_nested_grandchild_object_should_replace_tokens()
        {
            //Arrange
            var testObject = new TestObject {
                Prop1 = "@child.grandchild.property1@",
                Child = new ChildTestObject {
                    GrandChild = new ChildTestObject {
                        Property1 = "Test"
                    }
                }
            };

            //Act
            ObjectTextFieldTokenization.Tokenize(testObject);
            //Assert
            Assert.AreEqual("Test", testObject.Prop1);
        }
Beispiel #2
0
        public void Should_replace_tokens_on_grand_child_object()
        {
            //Arrange
            var testObject = new TestObject {
                Prop1 = "Test1",
                Child = new ChildTestObject {
                    GrandChild = new ChildTestObject {
                        Property1 = "@Prop1@"
                    }
                }
            };

            //Act
            ObjectTextFieldTokenization.Tokenize(testObject);
            //Assert
            Assert.AreEqual("Test1", testObject.Child.GrandChild.Property1);
        }
Beispiel #3
0
        public void Should_replace_tokens_on_child_object_collections()
        {
            //Arrange
            var testObject = new TestObject {
                Prop1            = "Test1",
                ObjectCollection = new[] {
                    new ChildTestObject {
                        Property1 = "@Prop1@"
                    }
                }
            };

            //Act
            ObjectTextFieldTokenization.Tokenize(testObject);
            //Assert
            Assert.AreEqual("Test1", testObject.ObjectCollection.FirstOrDefault().Property1);
        }
Beispiel #4
0
        public void Should_replace_token_when_token_is_in_child_object()
        {
            //Arrange
            var testObject = new TestObject {
                Child = new ChildTestObject {
                    Property1 = "@Prop1@"
                }
            };
            var lookupObj = new SecondTestObject {
                Prop1 = "Test1",
            };

            //Act
            ObjectTextFieldTokenization.Tokenize(testObject, lookupObj);
            //Assert
            Assert.AreEqual("Test1", testObject.Child.Property1);
        }
Beispiel #5
0
        public void When_tokens_have_dependencies_or_cascade_should_replace_all_tokens()
        {
            //Arrange
            var testObject = new TestObject {
                Prop1 = "Test1",
                Prop2 = "@prop1@",
                Child = new ChildTestObject {
                    Property1 = "@child.property2@",
                    Property2 = "@prop2@"
                }
            };

            //Act
            ObjectTextFieldTokenization.Tokenize(testObject);
            //Assert
            Assert.AreEqual("Test1", testObject.Prop2);
            Assert.AreEqual("Test1", testObject.Child.Property1);
            Assert.AreEqual("Test1", testObject.Child.Property2);
        }
Beispiel #6
0
        public void When_throwOnUnfound_is_true_incorrect_token_used_should_return_empty_string()
        {
            //Arrange
            var testObject = new TestObject {
                Prop1 = "Test1",
                Prop2 = "@prop@"
            };

            //Act
            try {
                ObjectTextFieldTokenization.ThrowOnUnfoundToken = true;

                ObjectTextFieldTokenization.Tokenize(testObject);
            } catch (Exception ex) {
                //Assert
                Assert.AreEqual("@prop@ token path not found in the object, check the token", ex.Message);
                throw;
            }
        }