Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2007-09-12 02:10:22 +0400
committerMarek Safar <marek.safar@gmail.com>2007-09-12 02:10:22 +0400
commitc5b0649eb409e7c3e7ce00629c2b7cc779e37159 (patch)
treee90e0a3930ed29d8701de6129eb036376085f8b3 /mcs/tests/gtest-linq-09.cs
parentcadf11dc596465d7f7248786ecbb5ce656c11690 (diff)
New test.
svn path=/trunk/mcs/; revision=85666
Diffstat (limited to 'mcs/tests/gtest-linq-09.cs')
-rw-r--r--mcs/tests/gtest-linq-09.cs80
1 files changed, 80 insertions, 0 deletions
diff --git a/mcs/tests/gtest-linq-09.cs b/mcs/tests/gtest-linq-09.cs
new file mode 100644
index 00000000000..a9fa22c70c3
--- /dev/null
+++ b/mcs/tests/gtest-linq-09.cs
@@ -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;
+ }
+}
+