PageRenderTime 81ms CodeModel.GetById 30ms RepoModel.GetById 12ms app.codeStats 0ms

/mcs/class/System.Data.Linq/src/DbLinq/Test/TableTest.cs

https://github.com/ztfuqingvip/mono
C# | 118 lines | 79 code | 16 blank | 23 comment | 0 complexity | 63afaa39927e8733bf3b02aa40e6dfce MD5 | raw file
Possible License(s): GPL-2.0, Unlicense, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0
  1. #region MIT license
  2. //
  3. // MIT license
  4. //
  5. // Copyright (c) 2009 Novell, Inc.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25. #endregion
  26. using System;
  27. using System.Collections.Generic;
  28. using System.Linq;
  29. #if MONO_STRICT
  30. using System.Data.Linq;
  31. #else
  32. using DbLinq.Data.Linq;
  33. #endif
  34. using NUnit.Framework;
  35. using DbLinq.Null;
  36. namespace DbLinqTest
  37. {
  38. [TestFixture]
  39. public class TableTest
  40. {
  41. Table<Person> people;
  42. [SetUp]
  43. public void SetUp()
  44. {
  45. people = new DataContext(new NullConnection() { ConnectionString = "" })
  46. .GetTable<Person>();
  47. }
  48. [TearDown]
  49. public void TearDown()
  50. {
  51. people = null;
  52. }
  53. [Test, ExpectedException(typeof(ArgumentNullException))]
  54. public void Attach_EntityNull()
  55. {
  56. people.Attach(null);
  57. }
  58. [Test, ExpectedException(typeof(ArgumentNullException))]
  59. public void AttachAll_EntitiesNull()
  60. {
  61. IEnumerable<Person> entities = null;
  62. people.AttachAll(entities);
  63. }
  64. [Test, ExpectedException(typeof(ArgumentNullException))]
  65. public void DeleteAllOnSubmit_EntitiesNull()
  66. {
  67. IEnumerable<Person> entities = null;
  68. people.DeleteAllOnSubmit(entities);
  69. }
  70. [Test, ExpectedException(typeof(ArgumentNullException))]
  71. public void DeleteOnSubmit_EntityNull()
  72. {
  73. people.DeleteOnSubmit(null);
  74. }
  75. [Test, ExpectedException(typeof(ArgumentNullException))]
  76. public void GetModifiedMembers_EntityNull()
  77. {
  78. people.GetModifiedMembers(null);
  79. }
  80. [Test, ExpectedException(typeof(ArgumentNullException))]
  81. public void GetOriginalEntityState_EntityNull()
  82. {
  83. people.GetOriginalEntityState(null);
  84. }
  85. [Test, ExpectedException(typeof(ArgumentNullException))]
  86. public void InsertAllOnSubmit_EntitiesNull()
  87. {
  88. IEnumerable<Person> entities = null;
  89. people.InsertAllOnSubmit(entities);
  90. }
  91. [Test, ExpectedException(typeof(ArgumentNullException))]
  92. public void InsertOnSubmit_EntityNull()
  93. {
  94. people.InsertOnSubmit(null);
  95. }
  96. [Test]
  97. public new void ToString()
  98. {
  99. Assert.AreEqual("Table(Person)", people.ToString());
  100. }
  101. }
  102. }