/mcs/class/System.Data.Linq/src/DbLinq/Test/Providers/Linq_101_Samples/Inheritance.cs

https://github.com/iainlane/mono
C# | 145 lines | 75 code | 35 blank | 35 comment | 2 complexity | bd148ac35e3a53a3f8e17584ad8f4a5a MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Test_NUnit;
  6. using NUnit.Framework;
  7. using Test_NUnit.Linq_101_Samples;
  8. using nwind;
  9. // test ns Linq_101_Samples
  10. #if MYSQL
  11. namespace Test_NUnit_MySql.Linq_101_Samples
  12. #elif ORACLE && ODP
  13. namespace Test_NUnit_OracleODP.Linq_101_Samples
  14. #elif ORACLE
  15. namespace Test_NUnit_Oracle.Linq_101_Samples
  16. #elif POSTGRES
  17. namespace Test_NUnit_PostgreSql.Linq_101_Samples
  18. #elif SQLITE
  19. namespace Test_NUnit_Sqlite.Linq_101_Samples
  20. #elif INGRES
  21. namespace Test_NUnit_Ingres.Linq_101_Samples
  22. #elif MSSQL && L2SQL
  23. namespace Test_NUnit_MsSql_Strict.Linq_101_Samples
  24. #elif MSSQL
  25. namespace Test_NUnit_MsSql.Linq_101_Samples
  26. #elif FIREBIRD
  27. namespace Test_NUnit_Firebird.Linq_101_Samples
  28. #endif
  29. {
  30. [TestFixture]
  31. public class Inheritance : TestBase
  32. {
  33. [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")]
  34. [Test(Description = "Simple. This sample returns all contacts where the city is London.")]
  35. public void LinqToSqlInheritance01()
  36. {
  37. Northwind db = CreateDB();
  38. Assert.Ignore();
  39. //var cons = from c in db.Contacts
  40. // select c;
  41. //var list = cons.ToList();
  42. //Assert.IsTrue(list.Count > 0);
  43. }
  44. [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")]
  45. [Test(Description = "OfType. This sample uses OfType to return all customer contacts.")]
  46. public void LinqToSqlInheritance02()
  47. {
  48. Northwind db = CreateDB();
  49. Assert.Ignore();
  50. //var cons = from c in newDB.Contacts.OfType<CustomerContact>()
  51. // select c;
  52. //var list = cons.ToList();
  53. //Assert.IsTrue(list.Count > 0);
  54. }
  55. [Linq101SamplesModified("This test could not be implemented since FullContact is not defined.")]
  56. [Test(Description = "CType. This sample uses CType to return FullContact or null.")]
  57. public void LinqToSqlInheritance04()
  58. {
  59. Northwind db = CreateDB();
  60. Assert.Ignore();
  61. //var cons = from c in newDB.Contacts
  62. // select (FullContact)c;
  63. //var list = cons.ToList();
  64. //Assert.IsTrue(list.Count > 0);
  65. }
  66. [Linq101SamplesModified("This test could not be implemented since CustomerContact is not defined.")]
  67. [Test(Description = "Cast. This sample uses a cast to retrieve customer contacts who live in London.")]
  68. public void LinqToSqlInheritance05()
  69. {
  70. Northwind db = CreateDB();
  71. Assert.Ignore();
  72. //var cons = from c in newDB.Contacts
  73. // where c.ContactType == "Customer" && (CustomerContact)c.City == "London"
  74. // select c;
  75. //var list = cons.ToList();
  76. //Assert.IsTrue(list.Count > 0);
  77. }
  78. [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")]
  79. [Test(Description = "UseAsDefault. This sample demonstrates that an unknown contact type will be automatically converted to the default contact type.")]
  80. public void LinqToSqlInheritance06()
  81. {
  82. Northwind db = CreateDB();
  83. Assert.Ignore();
  84. //var contact = new Contact() { ContactType = null, CompanyName = "Unknown Company", City = "London", Phone = "333-444-5555" };
  85. //db.Contacts.Add(contact);
  86. //db.SubmitChanges();
  87. //var con = (from c in db.Contacts
  88. // where c.ContactType == null
  89. // select c).First();
  90. }
  91. [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")]
  92. [Test(Description = "Insert New Record. This sample demonstrates how to create a new shipper contact.")]
  93. public void LinqToSqlInheritance07()
  94. {
  95. Northwind db = CreateDB();
  96. Assert.Ignore();
  97. //var ShipperContacts = from sc in newDB.Contacts.OfType<ShipperContact>()
  98. // where sc.CompanyName = "Northwind Shipper"
  99. // select sc;
  100. //var nsc = new ShipperContact() { CompanyName = "Northwind Shipper", Phone = "(123)-456-7890" };
  101. //db.Contacts.Add(nsc);
  102. //db.SubmitChanges();
  103. //ShipperContacts = from sc in db.Contacts.OfType<ShipperContact>()
  104. // where sc.CompanyName == "Northwind Shipper"
  105. // select sc;
  106. //newDB.Contacts.Remove(nsc);
  107. //newDB.SubmitChanges();
  108. }
  109. }
  110. }