* **/*: Flush. (Updates to sync with DbLinq r1026, correcting tests
[mono.git] / mcs / class / System.Data.Linq / src / DbLinq / Test / Providers / Linq_101_Samples / Inheritance.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Linq;\r
4 using System.Text;\r
5 using Test_NUnit;\r
6 using NUnit.Framework;\r
7 using Test_NUnit.Linq_101_Samples;\r
8 \r
9 using nwind;\r
10 \r
11 #if MYSQL\r
12 namespace Test_NUnit_MySql.Linq_101_Samples\r
13 #elif ORACLE\r
14 #if ODP\r
15         namespace Test_NUnit_OracleODP.Linq_101_Samples\r
16 #else\r
17         namespace Test_NUnit_Oracle.Linq_101_Samples\r
18 #endif\r
19 #elif POSTGRES\r
20     namespace Test_NUnit_PostgreSql.Linq_101_Samples\r
21 #elif SQLITE\r
22     namespace Test_NUnit_Sqlite.Linq_101_Samples\r
23 #elif INGRES\r
24     namespace Test_NUnit_Ingres.Linq_101_Samples\r
25 #elif MSSQL\r
26 #if MONO_STRICT\r
27     namespace Test_NUnit_MsSql_Strict.Linq_101_Samples\r
28 #else\r
29     namespace Test_NUnit_MsSql.Linq_101_Samples\r
30 #endif\r
31 #elif FIREBIRD\r
32     namespace Test_NUnit_Firebird\r
33 #else\r
34     #error unknown target\r
35 #endif\r
36 {\r
37     [TestFixture]\r
38     public class Inheritance : TestBase\r
39     {\r
40         [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]\r
41         [Test(Description = "Simple. This sample returns all contacts where the city is London.")]\r
42         public void LinqToSqlInheritance01()\r
43         {\r
44             Northwind db = CreateDB();\r
45 \r
46             Assert.Ignore();\r
47 \r
48             //var cons = from c in db.Contacts\r
49             //           select c;\r
50 \r
51             //var list = cons.ToList();\r
52             //Assert.IsTrue(list.Count > 0);\r
53         }\r
54 \r
55         [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]\r
56         [Test(Description = "OfType. This sample uses OfType to return all customer contacts.")]\r
57         public void LinqToSqlInheritance02()\r
58         {\r
59             Northwind db = CreateDB();\r
60 \r
61             Assert.Ignore();\r
62 \r
63             //var cons = from c in newDB.Contacts.OfType<CustomerContact>()\r
64             //           select c;\r
65 \r
66             //var list = cons.ToList();\r
67             //Assert.IsTrue(list.Count > 0);\r
68 \r
69         }\r
70 \r
71         [Linq101SamplesModified("This test could not be implemented since FullContact is not defined.")]\r
72         [Test(Description = "CType. This sample uses CType to return FullContact or null.")]\r
73         public void LinqToSqlInheritance04()\r
74         {\r
75             Northwind db = CreateDB();\r
76 \r
77             Assert.Ignore();\r
78 \r
79             //var cons = from c in newDB.Contacts\r
80             //           select (FullContact)c;\r
81 \r
82             //var list = cons.ToList();\r
83             //Assert.IsTrue(list.Count > 0);\r
84         }\r
85 \r
86         [Linq101SamplesModified("This test could not be implemented since CustomerContact is not defined.")]\r
87         [Test(Description = "Cast. This sample uses a cast to retrieve customer contacts who live in London.")]\r
88         public void LinqToSqlInheritance05()\r
89         {\r
90             Northwind db = CreateDB();\r
91 \r
92             Assert.Ignore();\r
93 \r
94             //var cons = from c in newDB.Contacts\r
95             //           where c.ContactType == "Customer" && (CustomerContact)c.City == "London"\r
96             //           select c;\r
97 \r
98             //var list = cons.ToList();\r
99             //Assert.IsTrue(list.Count > 0);\r
100 \r
101 \r
102         }\r
103 \r
104         [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]\r
105         [Test(Description = "UseAsDefault. This sample demonstrates that an unknown contact type will be automatically converted to the default contact type.")]\r
106         public void LinqToSqlInheritance06()\r
107         {\r
108             Northwind db = CreateDB();\r
109 \r
110             Assert.Ignore();\r
111 \r
112             //var contact = new Contact() { ContactType = null, CompanyName = "Unknown Company", City = "London", Phone = "333-444-5555" };\r
113             //db.Contacts.Add(contact);\r
114             //db.SubmitChanges();\r
115 \r
116             //var con = (from c in db.Contacts\r
117             //           where c.ContactType == null\r
118             //           select c).First();\r
119 \r
120         \r
121         }\r
122 \r
123         [Linq101SamplesModified("Original code did a reference to a newdb nortwhind that didn't exist, currently here uses db instead. Besides Contact type didn't exist")]\r
124         [Test(Description = "Insert New Record. This sample demonstrates how to create a new shipper contact.")]\r
125         public void LinqToSqlInheritance07()\r
126         {\r
127             Northwind db = CreateDB();\r
128 \r
129             Assert.Ignore();\r
130 \r
131             //var ShipperContacts = from sc in newDB.Contacts.OfType<ShipperContact>()\r
132             //                      where sc.CompanyName = "Northwind Shipper"\r
133             //                      select sc;\r
134 \r
135 \r
136             //var nsc = new ShipperContact() { CompanyName = "Northwind Shipper", Phone = "(123)-456-7890" };\r
137             //db.Contacts.Add(nsc);\r
138             //db.SubmitChanges();\r
139 \r
140 \r
141             //ShipperContacts = from sc in db.Contacts.OfType<ShipperContact>()\r
142             //                  where sc.CompanyName == "Northwind Shipper"\r
143             //                  select sc;\r
144 \r
145 \r
146             //newDB.Contacts.Remove(nsc);\r
147             //newDB.SubmitChanges();\r
148         }\r
149     }\r
150 }\r