public void NullableTargetConverter_SetNullableProperty_PropertyIsSet()
        {
            var sourceTestData = new NewSourceTestData();
            var targetTestData = new NewTargetTestData();

            var _ = new ObjectLinkBuilder(sourceTestData, targetTestData).Build();

            sourceTestData.IsVisible = true;

            Assert.True(targetTestData.IsVisible);

            sourceTestData.IsVisible = false;

            Assert.False(targetTestData.IsVisible);
        }
        public void NullableSourceConverter_SetProperty_NullablePropertyIsSet()
        {
            var sourceTestData = new NewSourceTestData();
            var targetTestData = new NewTargetTestData();

            var _ = new ObjectLinkBuilder(sourceTestData, targetTestData).Build();

            targetTestData.IsChecked = true;

            Assert.True(sourceTestData.IsChecked);

            targetTestData.IsChecked = false;

            Assert.False(sourceTestData.IsChecked);
        }
Beispiel #3
0
        public void LinkOneWayToTarget_InitialPropertiesSetBeforeLinking_TargetPropertyIsUpdated()
        {
            var sourceTestData = new NewSourceTestData {
                InitialText = "Test"
            };
            var targetTestData = new NewTargetTestData {
                InitialText = "1234"
            };

            var _ = new ObjectLinkBuilder(sourceTestData, targetTestData).Build();

            Assert.Equal("1234", sourceTestData.InitialText);

            sourceTestData.InitialText = "abc";
            Assert.Equal("abc", targetTestData.InitialText);
        }
Beispiel #4
0
        public void LinkTwoWay_SetPropertyOnInheritedClass_LinkedPropertyIsUpdated()
        {
            var sourceTestData = new SourceTestData();
            var targetTestData = new NewTargetTestData();

            var _ = new ObjectLinkBuilder(sourceTestData, targetTestData).Build();

            sourceTestData.TwoWayProperty = "Test";

            Assert.Equal("Test", targetTestData.TwoWayProperty);
            Assert.Equal("Test", sourceTestData.TwoWayProperty);

            targetTestData.TwoWayProperty = "1234";

            Assert.Equal("1234", sourceTestData.TwoWayProperty);
            Assert.Equal("1234", targetTestData.TwoWayProperty);
        }
        public void NullableSourceConverter_SetNullablePropertyWithDefault_PropertyIsSet()
        {
            var sourceTestData = new NewSourceTestData();
            var targetTestData = new NewTargetTestData();

            var _ = new ObjectLinkBuilder(sourceTestData, targetTestData).Build();

            sourceTestData.BoolWithDefault = true;

            Assert.True(targetTestData.BoolWithDefault);

            sourceTestData.BoolWithDefault = false;

            Assert.False(targetTestData.BoolWithDefault);

            sourceTestData.BoolWithDefault = null;

            Assert.True(targetTestData.BoolWithDefault);
        }
Beispiel #6
0
        public void LinkTwoWay_SetPropertyOnBothInheritedClasses_LinkedPropertyIsUpdated()
        {
            var sourceTestData = new NewSourceTestData();
            var targetTestData = new NewTargetTestData();

            var _ = new ObjectLinkBuilder(sourceTestData, targetTestData).Build();

            sourceTestData.TwoWayProperty = "Test";
            sourceTestData.SourceName     = "HelloWorld";

            Assert.Equal("Test", targetTestData.TwoWayProperty);
            Assert.Equal("Test", sourceTestData.TwoWayProperty);
            Assert.Equal("HelloWorld", targetTestData.FromSourceNameTwoWay);
            Assert.Equal("HelloWorld", sourceTestData.SourceName);

            targetTestData.TwoWayProperty       = "1234";
            targetTestData.FromSourceNameTwoWay = "abcd";

            Assert.Equal("1234", sourceTestData.TwoWayProperty);
            Assert.Equal("1234", targetTestData.TwoWayProperty);
            Assert.Equal("abcd", targetTestData.FromSourceNameTwoWay);
            Assert.Equal("abcd", sourceTestData.SourceName);
        }