I had a problem (page 190) following along after creating the LoadTests database and adding the method.
Code:
public void CurrentStatusDataTest()
{
var target = new Subscription();
var date = this.TestContext.DataRow["PaidUp"] as DateTime?;
if (date!=null)
{
target.PaidUpTo=date;
}
var val = Enum.Parse(typeof(Subscription.Status),
this.TestContext.DataRow["Status"] as string);
Assert.AreEqual(val, target.CurrentStatus, "Subscription.CurrentStatus was not set correctly.");
}
There was no recognition of the TestContext. The book did not seem to mention where to put the TestContext object suggesting that it was automatically generated. After looking at the downloadable code and seeing the field and property declared in the SubscriptionTest class
Code:
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
I was wondering if the book was negligent in mentioning what TestContext is, how it works, and when it should be inserted. Also a more expansive detail on how it relates to the DataSource property (step 3, page 189) would be helpful.