1 using Microsoft.VisualStudio.TestTools.UnitTesting;
 2 using SampleClassLib;
 3 using System;
 4 using System.IO;
 5 using System.Windows.Forms;
 6 
 7 namespace TestNamespace
 8 {
 9    [TestClass()]
10    public class DivideClassTest
11    {
12       [AssemblyInitialize()]
13       public static void AssemblyInit(TestContext context)
14       {
15          MessageBox.Show("Assembly Init");
16          }
17 
18       [ClassInitialize()]
19       public static void ClassInit(TestContext context)
20       {
21          MessageBox.Show("ClassInit");
22       }
23 
24       [TestInitialize()]
25       public void Initialize()
26       {
27          MessageBox.Show("TestMethodInit");
28       }
29 
30       [TestCleanup()]
31       public void Cleanup()
32       {
33          MessageBox.Show("TestMethodCleanup");
34       }
35 
36       [ClassCleanup()]
37       public static void ClassCleanup()
38       {
39          MessageBox.Show("ClassCleanup");
40       }
41 
42       [AssemblyCleanup()]
43       public static void AssemblyCleanup()
44       {
45          MessageBox.Show("AssemblyCleanup");
46       }
47 
48       [TestMethod()]
49       [ExpectedException(typeof(System.DivideByZeroException))]
50       public void DivideMethodTest()
51       {
52          DivideClass target = new DivideClass();
53          int a = 0; 
54          int actual;
55          actual = target.DivideMethod(a);
56       }
57    }
58 }

 

 
posted on 2012-07-17 15:36  cotopboy  阅读(286)  评论(0编辑  收藏  举报