Beispiel #1
0
        public void When_Updated_Source()
        {
            var SUT = new DataTemplate_Control();

            SUT.ForceLoaded();

            var _MyProperty = SUT.FindName("_MyProperty") as TextBlock;

            Assert.AreEqual("Initial", _MyProperty.Text);

            var _MyProperty_Function = SUT.FindName("_MyProperty_Function") as TextBlock;

            Assert.AreEqual("INITIAL", _MyProperty_Function.Text);

            var _MyProperty_Formatted = SUT.FindName("_MyProperty_Formatted") as TextBlock;

            Assert.AreEqual("Formatted Initial", _MyProperty_Formatted.Text);

            SUT.root.Content = new MyDataTemplateClass()
            {
                MyProperty = "Value 2"
            };

            Assert.AreEqual("Value 2", _MyProperty.Text);
            Assert.AreEqual("VALUE 2", _MyProperty_Function.Text);
            Assert.AreEqual("Formatted Value 2", _MyProperty_Formatted.Text);
        }
Beispiel #2
0
        public void When_Initial_Value()
        {
            var SUT = new DataTemplate_Control();

            SUT.ForceLoaded();

            var _MyProperty = SUT.FindName("_MyProperty") as TextBlock;

            Assert.AreEqual("Initial", _MyProperty.Text);

            var _MyProperty_Function = SUT.FindName("_MyProperty_Function") as TextBlock;

            Assert.AreEqual("INITIAL", _MyProperty_Function.Text);

            var _MyProperty_Formatted = SUT.FindName("_MyProperty_Formatted") as TextBlock;

            Assert.AreEqual("Formatted Initial", _MyProperty_Formatted.Text);
        }
Beispiel #3
0
        public void When_Updated_Property()
        {
            var SUT  = new DataTemplate_Control();
            var data = new MyDataTemplateClass();

            SUT.root.Content = data;

            SUT.ForceLoaded();

            var _MyProperty = SUT.FindName("_MyProperty") as TextBlock;

            Assert.AreEqual("Initial", _MyProperty.Text);

            var _MyProperty_Function = SUT.FindName("_MyProperty_Function") as TextBlock;

            Assert.AreEqual("INITIAL", _MyProperty_Function.Text);

            var _MyProperty_Formatted = SUT.FindName("_MyProperty_Formatted") as TextBlock;

            Assert.AreEqual("Formatted Initial", _MyProperty_Formatted.Text);

            var _MyProperty_Function_OneWay = SUT.FindName("_MyProperty_Function_OneWay") as TextBlock;

            Assert.AreEqual("INITIAL", _MyProperty_Function_OneWay.Text);

            var _MyProperty_Formatted_OneWay = SUT.FindName("_MyProperty_Formatted_OneWay") as TextBlock;

            Assert.AreEqual("Formatted Initial", _MyProperty_Formatted_OneWay.Text);

            Assert.AreEqual(9, data.MyPropertyGetCounter);

            data.MyProperty = "Other value";

            Assert.AreEqual("Initial", _MyProperty.Text);
            Assert.AreEqual("INITIAL", _MyProperty_Function.Text);
            Assert.AreEqual("Formatted Initial", _MyProperty_Formatted.Text);
            Assert.AreEqual("OTHER VALUE", _MyProperty_Function_OneWay.Text);
            Assert.AreEqual("Formatted Other value", _MyProperty_Formatted_OneWay.Text);

            Assert.AreEqual(13, data.MyPropertyGetCounter);
        }
Beispiel #4
0
        public void When_Loaded_Then_Reset()
        {
            var SUT  = new DataTemplate_Control();
            var data = new MyDataTemplateClass();

            SUT.root.Content = data;

            SUT.ForceLoaded();

            Assert.IsTrue(data.HasPropertyChangedListeners);

            var _MyProperty_Formatted_OneWay = SUT.FindName("_MyProperty_Formatted_OneWay") as TextBlock;

            Assert.AreEqual("Formatted Initial", _MyProperty_Formatted_OneWay.Text);

            data.MyProperty = "Other value";

            Assert.AreEqual("Formatted Other value", _MyProperty_Formatted_OneWay.Text);

            SUT.root.Content = null;

            Assert.IsFalse(data.HasPropertyChangedListeners);
        }