**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data.ObjectSpaces / Test / System.Data.ObjectSpaces / CommonObjectContextTests.cs
bloba383a08b62045527ea8b72426dd4166cc50e09d9
1 //
2 // System.Data.ObjectSpaces.CommonObjectContextTests.cs
3 //
4 // Author:
5 // Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2003
8 //
10 #if NET_2_0
12 using System;
13 using System.Data.ObjectSpaces;
14 using System.Data.ObjectSpaces.Schema;
15 using NUnit.Framework;
17 namespace MonoTests.System.Data.ObjectSpaces
19 [TestFixture]
20 public class CommonObjectContextTests : Assertion
22 CommonObjectContext context;
24 [SetUp]
25 public void GetReady ()
27 ObjectSchema schema = new ObjectSchema ();
28 context = new CommonObjectContext (schema);
31 [Test]
32 public void Add1 ()
34 try {
35 context.Add (null);
36 Fail ("Expected a ContextException to be thrown.");
37 } catch (ContextException) {}
39 try {
40 context.Add ("add1");
41 Fail ("Expected a NullReferenceException to be thrown.");
42 } catch (NullReferenceException) {}
45 [Test]
46 public void Add2 ()
48 try {
49 context.Add (null, ObjectState.Unknown);
50 Fail ("Expected a ContextException to be thrown.");
51 } catch (ContextException) {}
53 try {
54 context.Add ("add2", (ObjectState) (-1));
55 Fail ("Expected a NullReferenceException to be thrown.");
56 } catch (NullReferenceException) {}
58 try {
59 context.Add ("add2", ObjectState.Unknown);
60 Fail ("Expected a ContextException to be thrown.");
61 } catch (ContextException) {}
63 context.Add ("add2", ObjectState.Inserted);
66 [Test]
67 public void Delete ()
69 try {
70 context.Delete (null);
71 Fail ("Expected an ArgumentNullException to be thrown.");
72 } catch (ArgumentNullException) {}
77 #endif