Created
January 15, 2017 15:25
-
-
Save CopperStarSystems/dd8ef0a634fe629657f5facd5d83a0b2 to your computer and use it in GitHub Desktop.
Unit test class after integrating IPathWrapper with the ReallyHardToTest class
This file contains 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 NUnit.Framework; | |
using Moq; | |
[TestFixture] | |
public class ReallyHardToTestTests{ | |
Mock<IPathWrapper> mockPathWrapper; | |
// We will fix this soon... | |
SomeOtherDependency otherDependency; | |
ReallyHardToTest systemUnderTest; | |
[SetUp] | |
public void SetUp(){ | |
mockPathWrapper = new Mock<IPathWrapper>(MockBehavior.Strict); | |
otherDependency = new SomeOtherDependency(); | |
systemUnderTest = new ReallyHardToTest(otherDependency, mockPathWrapper.Object); | |
} | |
[TestCase(@"c:\some\path\filename.txt", "filename.txt")] | |
[TestCase(@"c:\some\really\long\path\otherFile.txt", "otherFile.txt")] | |
public void SetFilename_Always_InvokesPathGetFileName(string input, string expectedFilename){ | |
// Configure our mock expectations | |
mockPathWrapper.Setup(p=>p.GetFileName(input)).Returns(expectedFilename); | |
// Exercise our method under test | |
SystemUnderTest.SetFilename(input); | |
// Verify that our mock's expectations were met | |
mockPathWrapper.VerifyAll(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment