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)); }
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)); }
public void ClassWithIenumerableAndDataContract() { var widget = new ClassWithIenumerable2 { Property = "something" }; SerializerConsistencyHepers.Test(widget); // XML fails to serialize }
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)); }
public void PartialContract() { var c = new PartialDataContract { PropertyWithAttribute = "one", PropertyWithoutAttribute = "false" }; SerializerConsistencyHepers.Test(c); }
public void NormalClass() { var source = new NormalClass { FirstName = "John", LastName = "Smith", Item = "Socks" }; SerializerConsistencyHepers.Test(source); }
public void NullEmptyWhitespaceString() { NormalClass source = new NormalClass { FirstName = string.Empty, LastName = null, Item = " " }; SerializerConsistencyHepers.Test(source); }
public void PrivateProperty() { var source2 = new PrivateProperty { FirstName = "John", LastName = "Smith" }; source2.SetItem("shoes"); SerializerConsistencyHepers.Test(source2); }
public void Dictionary() { var dict = new Dictionary <string, int>(); dict["one"] = 1; dict["two"] = 2; SerializerConsistencyHepers.Test(dict); }
public Task Dictionary() { var dict = new Dictionary <string, int>(); dict["one"] = 1; dict["two"] = 2; return(SerializerConsistencyHepers.TestAsync(dict)); }
public Task PrivateProperty() { var source2 = new PrivateProperty { FirstName = "John", LastName = "Smith" }; source2.SetItem("shoes"); return(SerializerConsistencyHepers.TestAsync(source2)); }
public Task ClassWithFields() { var c1 = new ClassWithFields { Property = "prop" }; c1.SetField("field"); return(SerializerConsistencyHepers.TestAsync(c1)); }
public void ClassWithFields() { var c1 = new ClassWithFields { Property = "prop" }; c1.SetField("field"); SerializerConsistencyHepers.Test(c1); }
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)); }
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>)); }
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)); }
public void NewPropertiesHideBaseClass() { DerivedClassWithNew source = new DerivedClassWithNew { Property = "derived" }; BaseClass baseClass = (BaseClass)source; baseClass.Property = "base"; SerializerConsistencyHepers.Test(source, typeof(DerivedClassWithNew)); }
public void ExplicitInterfaceProps() { ClassWithExplicitInterface source = new ClassWithExplicitInterface { PublicProp = "public" }; Interface1 i1 = source; i1.Foo = "interface!"; SerializerConsistencyHepers.Test(source); SerializerConsistencyHepers.Test(source, typeof(Interface1)); }
public Task Array() { string[] array = new string[] { "First", "Second", "Last" }; return(SerializerConsistencyHepers.TestAsync(array)); }
public void Array() { string[] array = new string[] { "First", "Second", "Last" }; SerializerConsistencyHepers.Test(array); }
public void TestAnonymousType() { var anonymous = new { X = 10, Y = 15 }; SerializerConsistencyHepers.Test(anonymous); // XML fails to write anonymous types }
public Task StaticProps() { ClassWithStaticProperties source = new ClassWithStaticProperties(); return(SerializerConsistencyHepers.TestAsync(source)); }
public void StaticProps() { ClassWithStaticProperties source = new ClassWithStaticProperties(); SerializerConsistencyHepers.Test(source); }