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

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

https://github.com/ekovalenko-softheme/mono
C# | 118 lines | 79 code | 16 blank | 23 comment | 0 complexity | 63afaa39927e8733bf3b02aa40e6dfce 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.Generic;
 29using System.Linq;
 30
 31#if MONO_STRICT
 32using System.Data.Linq;
 33#else
 34using DbLinq.Data.Linq;
 35#endif
 36
 37using NUnit.Framework;
 38
 39using DbLinq.Null;
 40
 41namespace DbLinqTest
 42{
 43    [TestFixture]
 44    public class TableTest
 45    {
 46        Table<Person> people;
 47
 48        [SetUp]
 49        public void SetUp()
 50        {
 51            people = new DataContext(new NullConnection() { ConnectionString = "" })
 52                .GetTable<Person>();
 53        }
 54
 55        [TearDown]
 56        public void TearDown()
 57        {
 58            people = null;
 59        }
 60
 61        [Test, ExpectedException(typeof(ArgumentNullException))]
 62        public void Attach_EntityNull()
 63        {
 64            people.Attach(null);
 65        }
 66
 67        [Test, ExpectedException(typeof(ArgumentNullException))]
 68        public void AttachAll_EntitiesNull()
 69        {
 70            IEnumerable<Person> entities = null;
 71            people.AttachAll(entities);
 72        }
 73
 74        [Test, ExpectedException(typeof(ArgumentNullException))]
 75        public void DeleteAllOnSubmit_EntitiesNull()
 76        {
 77            IEnumerable<Person> entities = null;
 78            people.DeleteAllOnSubmit(entities);
 79        }
 80
 81        [Test, ExpectedException(typeof(ArgumentNullException))]
 82        public void DeleteOnSubmit_EntityNull()
 83        {
 84            people.DeleteOnSubmit(null);
 85        }
 86
 87        [Test, ExpectedException(typeof(ArgumentNullException))]
 88        public void GetModifiedMembers_EntityNull()
 89        {
 90            people.GetModifiedMembers(null);
 91        }
 92
 93        [Test, ExpectedException(typeof(ArgumentNullException))]
 94        public void GetOriginalEntityState_EntityNull()
 95        {
 96            people.GetOriginalEntityState(null);
 97        }
 98
 99        [Test, ExpectedException(typeof(ArgumentNullException))]
100        public void InsertAllOnSubmit_EntitiesNull()
101        {
102            IEnumerable<Person> entities = null;
103            people.InsertAllOnSubmit(entities);
104        }
105
106        [Test, ExpectedException(typeof(ArgumentNullException))]
107        public void InsertOnSubmit_EntityNull()
108        {
109            people.InsertOnSubmit(null);
110        }
111
112        [Test]
113        public new void ToString()
114        {
115            Assert.AreEqual("Table(Person)", people.ToString());
116        }
117    }
118}