Overview
This is an open source, .NET Framework 4.6 library that provides helpers for using MSTest (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.MSTest NuGet package run the following command in the Package Manager Console:
1PM> Install-Package ChannelAdam.TestFramework.MSTest
Usage
1using ChannelAdam.TestFramework.MSTest.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 }
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
.
comments powered by Disqus