Created
April 5, 2017 06:37
-
-
Save nojaf/2449a36e7621f0fec35b4d7ace39b4b0 to your computer and use it in GitHub Desktop.
MStest cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |
| using SampleClassLib; | |
| using System; | |
| using System.Windows.Forms; | |
| namespace TestNamespace | |
| { | |
| [TestClass()] | |
| public sealed class DivideClassTest | |
| { | |
| [AssemblyInitialize()] | |
| public static void AssemblyInit(TestContext context) | |
| { | |
| MessageBox.Show("AssemblyInit " + context.TestName); | |
| } | |
| [ClassInitialize()] | |
| public static void ClassInit(TestContext context) | |
| { | |
| MessageBox.Show("ClassInit " + context.TestName); | |
| } | |
| [TestInitialize()] | |
| public void Initialize() | |
| { | |
| MessageBox.Show("TestMethodInit"); | |
| } | |
| [TestCleanup()] | |
| public void Cleanup() | |
| { | |
| MessageBox.Show("TestMethodCleanup"); | |
| } | |
| [ClassCleanup()] | |
| public static void ClassCleanup() | |
| { | |
| MessageBox.Show("ClassCleanup"); | |
| } | |
| [AssemblyCleanup()] | |
| public static void AssemblyCleanup() | |
| { | |
| MessageBox.Show("AssemblyCleanup"); | |
| } | |
| [TestMethod()] | |
| [ExpectedException(typeof(System.DivideByZeroException))] | |
| public void DivideMethodTest() | |
| { | |
| DivideClass.DivideMethod(0); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment