예제 #1
0
        public void LinqDirect()
        {
            var l = from i in Enumerable.Range(1, 10) where i > 5 select i * i;

            // Write as the derived runtime type, but then read back as just an IEnumerable.
            SerializerConsistencyHepers.Test(l, tSourceWrite: l.GetType(), tSourceRead: typeof(IEnumerable <int>));
        }
        public Task NullEmptyWhitespaceString()
        {
            NormalClass source = new NormalClass {
                FirstName = string.Empty, LastName = null, Item = "   "
            };

            return(SerializerConsistencyHepers.TestAsync(source));
        }
예제 #3
0
        public void ArrayInterfaces()
        {
            string[] array = new string[] { "First", "Second", "Last" };

            SerializerConsistencyHepers.Test(array, typeof(IList <string>));
            SerializerConsistencyHepers.Test(array, typeof(ICollection <string>));
            SerializerConsistencyHepers.Test(array, typeof(IEnumerable <string>));
        }
        public Task PartialContract()
        {
            var c = new PartialDataContract {
                PropertyWithAttribute = "one", PropertyWithoutAttribute = "false"
            };

            return(SerializerConsistencyHepers.TestAsync(c));
        }
예제 #5
0
        public void ClassWithIenumerableAndDataContract()
        {
            var widget = new ClassWithIenumerable2 {
                Property = "something"
            };

            SerializerConsistencyHepers.Test(widget); // XML fails to serialize
        }
예제 #6
0
        public void Linq()
        {
            var l = from i in Enumerable.Range(1, 10) where i > 5 select i * i;

            // Runtime type of a linq expression is some derived Linq type which we can't deserialize to.
            // So explicitly call out IEnumerable<T>
            SerializerConsistencyHepers.Test(l, typeof(IEnumerable <int>));
        }
        public Task NormalClass()
        {
            var source = new NormalClass {
                FirstName = "John", LastName = "Smith", Item = "Socks"
            };

            return(SerializerConsistencyHepers.TestAsync(source));
        }
예제 #8
0
        public void PartialContract()
        {
            var c = new PartialDataContract {
                PropertyWithAttribute = "one", PropertyWithoutAttribute = "false"
            };

            SerializerConsistencyHepers.Test(c);
        }
예제 #9
0
        public void NormalClass()
        {
            var source = new NormalClass {
                FirstName = "John", LastName = "Smith", Item = "Socks"
            };

            SerializerConsistencyHepers.Test(source);
        }
예제 #10
0
        public void NullEmptyWhitespaceString()
        {
            NormalClass source = new NormalClass {
                FirstName = string.Empty, LastName = null, Item = "   "
            };

            SerializerConsistencyHepers.Test(source);
        }
예제 #11
0
        public void PrivateProperty()
        {
            var source2 = new PrivateProperty {
                FirstName = "John", LastName = "Smith"
            };

            source2.SetItem("shoes");
            SerializerConsistencyHepers.Test(source2);
        }
예제 #12
0
        public void Dictionary()
        {
            var dict = new Dictionary <string, int>();

            dict["one"] = 1;
            dict["two"] = 2;

            SerializerConsistencyHepers.Test(dict);
        }
예제 #13
0
        public Task Dictionary()
        {
            var dict = new Dictionary <string, int>();

            dict["one"] = 1;
            dict["two"] = 2;

            return(SerializerConsistencyHepers.TestAsync(dict));
        }
예제 #14
0
        public Task PrivateProperty()
        {
            var source2 = new PrivateProperty {
                FirstName = "John", LastName = "Smith"
            };

            source2.SetItem("shoes");
            return(SerializerConsistencyHepers.TestAsync(source2));
        }
예제 #15
0
        public Task ClassWithFields()
        {
            var c1 = new ClassWithFields {
                Property = "prop"
            };

            c1.SetField("field");
            return(SerializerConsistencyHepers.TestAsync(c1));
        }
예제 #16
0
        public void ClassWithFields()
        {
            var c1 = new ClassWithFields {
                Property = "prop"
            };

            c1.SetField("field");
            SerializerConsistencyHepers.Test(c1);
        }
예제 #17
0
        public void InheritedProperties()
        {
            // Will we pick up inherited properties from a base object?
            BaseClass source = new DerivedClass {
                Property = "base", DerivedProperty = "derived"
            };

            source.SetField("private");
            SerializerConsistencyHepers.Test(source, typeof(DerivedClass));
        }
예제 #18
0
        public async Task ArrayInterfaces()
        {
            string[] array = new string[] { "First", "Second", "Last" };

            await SerializerConsistencyHepers.TestAsync(array, typeof(IList <string>));

            await SerializerConsistencyHepers.TestAsync(array, typeof(ICollection <string>));

            await SerializerConsistencyHepers.TestAsync(array, typeof(IEnumerable <string>));
        }
예제 #19
0
        public void DerivedProperties()
        {
            // If the static type is the base object, will we see the runtime type and pick derived properties
            BaseClass source = new DerivedClass {
                Property = "base", DerivedProperty = "derived"
            };

            source.SetField("private");
            SerializerConsistencyHepers.Test(source, typeof(BaseClass));
        }
예제 #20
0
        public void NewPropertiesHideBaseClass()
        {
            DerivedClassWithNew source = new DerivedClassWithNew {
                Property = "derived"
            };
            BaseClass baseClass = (BaseClass)source;

            baseClass.Property = "base";

            SerializerConsistencyHepers.Test(source, typeof(DerivedClassWithNew));
        }
예제 #21
0
        public void ExplicitInterfaceProps()
        {
            ClassWithExplicitInterface source = new ClassWithExplicitInterface {
                PublicProp = "public"
            };
            Interface1 i1 = source;

            i1.Foo = "interface!";

            SerializerConsistencyHepers.Test(source);
            SerializerConsistencyHepers.Test(source, typeof(Interface1));
        }
예제 #22
0
        public Task Array()
        {
            string[] array = new string[] { "First", "Second", "Last" };

            return(SerializerConsistencyHepers.TestAsync(array));
        }
예제 #23
0
        public void Array()
        {
            string[] array = new string[] { "First", "Second", "Last" };

            SerializerConsistencyHepers.Test(array);
        }
예제 #24
0
        public void TestAnonymousType()
        {
            var anonymous = new { X = 10, Y = 15 };

            SerializerConsistencyHepers.Test(anonymous); // XML fails to write anonymous types
        }
예제 #25
0
        public Task StaticProps()
        {
            ClassWithStaticProperties source = new ClassWithStaticProperties();

            return(SerializerConsistencyHepers.TestAsync(source));
        }
예제 #26
0
        public void StaticProps()
        {
            ClassWithStaticProperties source = new ClassWithStaticProperties();

            SerializerConsistencyHepers.Test(source);
        }