示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#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);
        }
示例#4
0
        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);
        }
示例#5
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);
        }