The ChannelAdam Test Framework MSTest V2 Library
Overview
This is an open source, .NET Standard 1.3 library that provides helpers for using MSTest V2 (and Moq) on top of the ChannelAdam Test Framework Library.
Below are the main features of the library. See the linked code for details.
Please contact me if you have any questions.
Getting Started
NuGet Package Installation
To install the ChannelAdam.TestFramework.MSTestV2 NuGet package run the following command in the Package Manager Console:
1PM> Install-Package ChannelAdam.TestFramework.MSTestV2
Usage
1using ChannelAdam.TestFramework.MSTestV2.Abstractions;
2...
3 [TestClass]
4 public class MyUnitTests : MoqTestFixture
5 {
6 Mock<IMyService> _mockMyService;
7
8 [TestMethod]
9 public void MyTestMethodWithMockObjects()
10 {
11 // ARRANGE
12 _mockMyService = base.MyMockRepository.Create<IMyService>();
13 _mockMyService.Setup(...)
14 .Returns(...);
15
16 // ACT
17 ...
18
19 // ASSERT
20 LogAssert...
21
22 Logger.Log("Verifying all mock expectations were met");
23 MyMockRepository.VerifyAll();
24 }
25
26 [TestMethod]
27 public void MyTestMethod()
28 {
29 // ARRANGE
30 bool isOrderLateExpected = false;
31
32 // ACT
33 Logger.Log("About to do the ACT part of blah blah... so the test output reads like a story");
34 bool isOrderLateActual = true;
35
36 // ASSERT
37 LogAssert.AreEqual("isOrderLate", isOrderLateExpected, isOrderLateActual);
38 // Test Output: "Asserting isOrderLate is equal to: false"
39 }
40 }
See MakingSoap12UnitSteps.cs for an example of using the TestEasy
base class directly without Moq.
Reference
MoqTestFixture inherits from the ChannelAdam Test Framework Moq Library MoqTestFixture
class to provide Moq MockRepository
functionality on top of its own extension of TestEasy.
Please see the ChannelAdam Test Framework Library documentation for more information about TestEasy
.