PageRenderTime 2ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

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