我有一个测试方法,运行时很好,但在调试时会因异常而失败。 下面是测试过的方法和VS Test Runner的输出。异常来自ShimsContext.Create()。
信息:VS 2012 Permium Update2
[TestMethod]
public void TestResolveDateWithShim()
{
using (ShimsContext.Create())
{
// arrange
DateTime someTestTime = new DateTime(2013, 1, 14);
Fakes.ShimDateHelper.PreviousOrCurrentQuarterEndDateTime =
time => someTestTime;
var appCache = new Fakes.StubIAppCache();
var series = new StubISeries();
series.KeyGet = () => SeriesKey.MyKey;
// act
Report report = new Report(SeriesKey.MyKey, appCache);
DateTime resolvedDate = report.ResolveDate(series, DateTime.Now);
// assert
Assert.AreEqual(someTestTime, someTestTime);
}