// (C) 2003 Martin Willemoes Hansen
//
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using NUnit.Framework;
using System;
using System.Data;
// }
[TestFixture]
- public class ConstraintTest
+ public class ConstraintTest : Assertion
{
private DataTable _table;
private Constraint _constraint1;
exceptionCaught = true;
}
catch {
- Assertion.Fail("Wrong exception type thrown.");
+ Fail("Wrong exception type thrown.");
}
- Assertion.Assert("Failed to throw exception.",
+ Assert("Failed to throw exception.",
true == exceptionCaught);
}
}
[Test]
- public void SetConstraintNameDuplicateException() {
+ [ExpectedException (typeof (DuplicateNameException))]
+ public void SetConstraintNameDuplicateException ()
+ {
_constraint1.ConstraintName = "Dog";
_constraint2.ConstraintName = "Cat";
_table.Constraints.Add(_constraint1);
_table.Constraints.Add(_constraint2);
- try {
- //Should throw DuplicateNameException
- _constraint2.ConstraintName = "Dog";
-
- Assertion.Fail("Failed to throw " +
- " DuplicateNameException exception.");
- }
- catch (DuplicateNameException) {}
- catch (AssertionException exc) {throw exc;}
- catch {
- Assertion.Fail("Wrong exception type thrown.");
- }
-
+ //Should throw DuplicateNameException
+ _constraint2.ConstraintName = "Dog";
}
[Test]
public void ToStringTest() {
_constraint1.ConstraintName = "Test";
- Assertion.Assert("ToString is the same as constraint name.", _constraint1.ConstraintName.CompareTo( _constraint1.ToString()) == 0);
+ Assert("ToString is the same as constraint name.", _constraint1.ConstraintName.CompareTo( _constraint1.ToString()) == 0);
_constraint1.ConstraintName = null;
- Assertion.AssertNotNull("ToString should return empty.",_constraint1.ToString());
+ AssertNotNull("ToString should return empty.",_constraint1.ToString());
}
[Test]
PropertyCollection col = _constraint1.ExtendedProperties as
PropertyCollection;
- Assertion.AssertNotNull("ExtendedProperties returned null or didn't " +
+ AssertNotNull("ExtendedProperties returned null or didn't " +
"return the correct type", col);
}
}