Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Forked from anonymous/test.cs
Created October 13, 2011 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiftkey/1283166 to your computer and use it in GitHub Desktop.
Save shiftkey/1283166 to your computer and use it in GitHub Desktop.
Good test/ bad test?
[TestMethod]
public void GetContextId_OnSecondRun_ReturnsStoredContextId() // "should" is a grey phrase
{
const string firstId = "200"; // context is used a lot in the test - removed here
const string secondId = "400"; // and i isolate these from my arrange for readability
// arrange
var record = new ContextRecord();
fakeRecordGenerator.Generate().Returns(record); // overuse of "Record" in here? necessary?
fakeContextService.CreateContext(record).Returns(firstId);
contextManager.GetContextId(); // why do we need to set the mock behaviour twice?
fakeContextService.CreateContext(record).Returns(secondId);
// act
var resultContextId = contextManager.GetContextId();
Assert.AreEqual(firstContextId, resultContextId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment