PageRenderTime 50ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/ztfuqingvip/mono
C# | 82 lines | 51 code | 8 blank | 23 comment | 0 complexity | 9ea6d6a7554652bf8c85a14fd8b6c3dc 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;
  28. using System.Collections.Generic;
  29. using System.Collections.ObjectModel;
  30. using System.Data.SqlClient;
  31. using System.IO;
  32. using System.Linq;
  33. using System.Reflection;
  34. using System.Data.Linq.Mapping;
  35. #if MONO_STRICT
  36. using System.Data.Linq;
  37. using AttributeMappingSource = System.Data.Linq.Mapping.AttributeMappingSource;
  38. #else
  39. using DbLinq.Data.Linq;
  40. using AttributeMappingSource = DbLinq.Data.Linq.Mapping.AttributeMappingSource;
  41. #endif
  42. using DbLinq.Null;
  43. using NUnit.Framework;
  44. namespace DbLinqTest
  45. {
  46. [Table(Name = "dbo...FooTable")]
  47. class Foo
  48. {
  49. [Column(Name="Col1")]
  50. public string Column1 { get; set; }
  51. }
  52. [Database(Name = "MyDB1")]
  53. class MyDataContext2 : DataContext
  54. {
  55. public MyDataContext2()
  56. : base(new SqlConnection("Data Source=localhost"))
  57. {
  58. }
  59. public Table<Foo> FooTable { get { return GetTable<Foo>(); } }
  60. public Table<Foo> FooFieldTable;
  61. }
  62. [TestFixture]
  63. public class AttributeMappingSourceTest
  64. {
  65. [Test]
  66. public void CreateModel_GetTables_Has_No_Duplicates()
  67. {
  68. var model = new AttributeMappingSource().GetModel(typeof(MyDataContext2));
  69. var tables = model.GetTables().ToList();
  70. Assert.AreEqual(1, tables.Count);
  71. Assert.AreEqual("dbo...FooTable", tables[0].TableName);
  72. }
  73. }
  74. }