2009-02-20 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / class / doc / TemplateTest.cs
blobc255a141f209742f3b606f91c50bbc010993d817
1 // this is a template for making NUnit version 2 tests. Text enclosed in curly
2 // brackets (and the brackets themselves) should be replaced by appropriate
3 // code.
5 // {File Name}.cs - NUnit Test Cases for {explain here}
6 //
7 // {Author Name} ({Author email Address})
8 //
9 // (C) {Copyright holder}
10 //
12 // these are the standard namespaces you will need. You may need to add more
13 // depending on your tests.
14 using NUnit.Framework;
15 using System;
17 // all test namespaces start with "MonoTests." Append the Namespace that
18 // contains the class you are testing, e.g. MonoTests.System.Collections
19 namespace MonoTests.{Namespace}
22 // the class name should end with "Test" and start with the name of the class
23 // you are testing, e.g. CollectionBaseTest
24 [TestFixture]
25 public class {Class to be tested}Test : Assertion {
27 // this method is run before each [Test] method is called. You can put
28 // variable initialization, etc. here that is common to each test.
29 // Just leave the method empty if you don't need to use it.
30 // The name of the method does not matter; the attribute does.
31 [SetUp]
32 public void GetReady() {}
34 // this method is run after each Test* method is called. You can put
35 // clean-up code, etc. here. Whatever needs to be done after each test.
36 // Just leave the method empty if you don't need to use it.
37 // The name of the method does not matter; the attribute does.
38 [TearDown]
39 public void Clean() {}
41 // this is just one of probably many test methods in your test class.
42 // each test method must be adorned with [Test]. All methods in your class
43 // adorned with [Test] will be automagically called by the NUnit
44 // framework.
45 [Test]
46 public void {Something} {
47 // inside here you will exercise your class and then call Assert()
50 // An nice way to test for exceptions the class under test should
51 // throw is:
53 [Test]
54 [ExpectedException(typeof(ArgumentNullException))]
55 public void OnValid() {
56 ConcreteCollection myCollection;
57 myCollection = new ConcreteCollection();
58 ....
59 AssertEquals ("#UniqueID", expected, actual);
60 ....
61 Fail ("Message");