add ISafeSerializationData
[mcs.git] / tests / gtest-anontype-05.cs
blobbda008c2fafc0e48b18b3f6370fcc66c306edb96
2 // Tests anonymous type consolidation
4 using System;
5 using System.Collections;
7 public class Test
9 static string Null ()
11 return null;
14 static int Main ()
16 var v1 = new { Name = "Scott", Age = 21 };
17 var v2 = new { Age = 20, Name = "Sam" };
18 var v3 = new { Name = Null (), Age = 33 };
20 if (v1.GetType () == v2.GetType ())
21 return 1;
23 if (v1.Equals (v2))
24 return 2;
26 if (v1.GetType () != v3.GetType ())
27 return 3;
29 if (!v1.Equals (v1))
30 return 4;
32 if (v1.GetHashCode () != v1.GetHashCode ())
33 return 5;
35 Console.WriteLine (v1);
36 Console.WriteLine (v3);
38 if (v1.ToString () != "{ Name = Scott, Age = 21 }")
39 return 6;
41 if (v3.ToString () != "{ Name = , Age = 33 }")
42 return 7;
44 var v4 = new {};
46 if (v4.ToString () != "{ }")
47 return 8;
49 var v5 = new { Foo = "Bar" };
50 var v6 = new { Foo = Null () };
52 if (v5.ToString () != "{ Foo = Bar }")
53 return 9;
55 if (v6.ToString () != "{ Foo = }")
56 return 10;
58 return 0;