Author: marek
Date: 2007-09-11 18:10:22 -0400 (Tue, 11 Sep 2007)
New Revision: 85666

Added:
   trunk/mcs/tests/gtest-linq-09.cs
Log:
New test.



Added: trunk/mcs/tests/gtest-linq-09.cs
===================================================================
--- trunk/mcs/tests/gtest-linq-09.cs    2007-09-11 22:09:59 UTC (rev 85665)
+++ trunk/mcs/tests/gtest-linq-09.cs    2007-09-11 22:10:22 UTC (rev 85666)
@@ -0,0 +1,80 @@
+// Compiler options: -langversion:linq
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+class Data
+{
+       public int Key;
+       public string Value;
+}
+
+class Join
+{
+       public static int Main ()
+       {
+               Data[] d1 = new Data[] { new Data () { Key = 1, Value = "First" 
} };
+               Data[] d2 = new Data[] { 
+                       new Data () { Key = 1, Value = "Second" },
+                       new Data () { Key = 1, Value = "Third" }
+               };
+
+               
+               var e = from a in d1
+                       join b in d2 on a.Key equals b.Key
+                       select new { Result = a.Value + b.Value };
+
+               var res = e.ToList ();
+               if (res.Count != 2)
+                       return 1;
+               
+               if (res [0].Result != "FirstSecond")
+                       return 2;
+                       
+               if (res [1].Result != "FirstThird")
+                       return 3;
+                       
+               e = from Data a in d1
+                       join b in d2 on a.Key equals b.Key
+                       where b.Value == "Second"
+                       select new { Result = a.Value + b.Value };
+                       
+               res = e.ToList ();
+               if (res.Count != 1)
+                       return 4;
+               
+               if (res [0].Result != "FirstSecond")
+                       return 5;               
+                       
+               // Explicitly typed
+               e = from Data a in d1
+            join Data b in d2 on a.Key equals b.Key
+            select new { Result = a.Value + b.Value };
+               
+               res = e.ToList ();
+               if (res.Count != 2)
+                       return 10;
+               
+               if (res [0].Result != "FirstSecond")
+                       return 11;
+                       
+               if (res [1].Result != "FirstThird")
+                       return 12;
+               
+               var e2 = from Data a in d1
+                       join b in d2 on a.Key equals b.Key
+                       group b by a.Key;
+
+               var res2 = e2.ToList ();
+               if (res2.Count != 1)
+                       return 20;
+               
+               if (res2 [0].Key != 1)
+                       return 21;
+                       
+               Console.WriteLine ("OK");
+               return 0;
+       }
+}
+

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to