public void SerializeWithDefaultValue()
        {
            FooWithBar whatever = new FooWithBar {
                Bar = 12
            };
            FooWithBar another = new FooWithBar {
                Bar = 13
            };
            object list = new List <string>();

            SetValueWithDefault(whatever, "Something2");
            SetValueWithDefault(list, "Default string");
            SetValueWithDefault(another, "Nagging2");

            object[] data = new object[] { whatever, another, list };

            var xaml =
                @"<x:Array Type=""x:Object"" xmlns=""clr-namespace:DrtXaml.Tests;assembly=DrtXaml"" xmlns:scg=""clr-namespace:System.Collections.Generic;assembly={0}"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
  <FooWithBar Bar=""12"" AttachablePropertyServicesTests.ValueWithDefault=""Something2"" />
  <FooWithBar Bar=""13"" AttachablePropertyServicesTests.ValueWithDefault=""Nagging2"" />
  <scg:List x:TypeArguments=""x:String"" Capacity=""0"" />
</x:Array>";

            xaml = string.Format(xaml, typeof(object[]).GetAssemblyName());

            string generated = XamlServices.Save(data);

            Assert.AreEqual(xaml, generated);


            //var result = RoundTrip(data, xaml);
            //Assert.IsNotNull(result);
        }
        public void SerializeWithAPSComplexProperty()
        {
            var ap = new ComplexAttachedProperty()
            {
                Bar = "something", Foo = 65
            };
            FooWithBar f = new FooWithBar()
            {
                Bar = 12,
            };

            SetComplex(f, ap);

            Assert.IsTrue(GetComplex(f).Equals(ap));
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(f) == 1);

            var        expected = @"<FooWithBar Bar=""12"" xmlns=""clr-namespace:DrtXaml.Tests;assembly=DrtXaml"">
  <AttachablePropertyServicesTests.Complex>
    <ComplexAttachedProperty Bar=""something"" Foo=""65"" />
  </AttachablePropertyServicesTests.Complex>
</FooWithBar>";
            FooWithBar result   = (FooWithBar)RoundTrip(f, expected);

            Assert.IsTrue(result.Bar == 12);
            Assert.IsTrue(GetComplex(result).Equals(ap));
        }
        public void SerializeWithAPSProperty()
        {
            FooWithBar f = new FooWithBar()
            {
                Bar = 12
            };

            SetBar(f, 17);

            Assert.IsTrue(GetBar(f) == 17);
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(f) == 1);

            var        expected = @"<FooWithBar AttachablePropertyServicesTests.Bar=""17"" Bar=""12"" xmlns=""clr-namespace:DrtXaml.Tests;assembly=DrtXaml"" />";
            FooWithBar result   = (FooWithBar)RoundTrip(f, expected);

            Assert.IsTrue(result.Bar == 12);
            Assert.IsTrue(GetBar(result) == 17);
        }
        public void SerializeWithHiddenAPSProperties()
        {
            FooWithBar f = new FooWithBar()
            {
                Bar = 12
            };

            SetNonSerialized(f, 17);
            SetNonSerialized2(f, "Something");

            Assert.IsTrue(GetNonSerialized(f) == 17);
            Assert.IsTrue(GetNonSerialized2(f) == "Something");
            Assert.IsTrue(AttachablePropertyServices.GetAttachedPropertyCount(f) == 2);

            var        expected = @"<FooWithBar Bar=""12"" xmlns=""clr-namespace:DrtXaml.Tests;assembly=DrtXaml"" />";
            FooWithBar result   = (FooWithBar)RoundTrip(f, expected);

            Assert.IsTrue(result.Bar == 12);
            Assert.IsTrue(GetNonSerialized(result) == 0);
            Assert.IsTrue(GetNonSerialized2(result) == String.Empty);
        }