mardi 6 janvier 2015

What Block Isn't Covered?

Visual Studio 2013 is showing my code coverage for this (simplified for this example) object as missing a block:


code coverage


As far as I know, that if should have exactly two states. Pass and fail. And debugging my tests shows that each of those conditions is executed once. Specifically with these two tests:



[TestMethod]
public void CanNotHaveNegativeServiceWindow()
{
// arrange
var request = new CreateCaseRequest
{
ServiceWindowStart = new DateTime(2014, 12, 31, 12, 00, 00),
ServiceWindowEnd = new DateTime(2014, 12, 31, 11, 00, 00)
};

// act
var result = request.GetValidationErrors();

// assert
Assert.AreEqual(1, result.Count());
}

[TestMethod]
public void CanHaveServiceWindow()
{
// arrange
var request = new CreateCaseRequest
{
ServiceWindowStart = new DateTime(2014, 12, 31, 11, 00, 00),
ServiceWindowEnd = new DateTime(2014, 12, 31, 12, 00, 00)
};

// act
var result = request.GetValidationErrors();

// assert
Assert.AreEqual(0, result.Count());
}


One test validates the positive result of that specific if condition, the other validates the negative result. What block isn't covered? What logical condition exists that I'm missing?


Aucun commentaire:

Enregistrer un commentaire