1

当我创建我的 moq 模拟并尝试将其传递给我的类构造函数时,我收到以下消息:Argument type Moq.Mock<...mockIAppCache> is not assingable to paramter type 'IAppCache'。我包含了该库,并且可以找到对 Mock() 的引用。我在这里错过了什么吗?

    [TestMethod]
    public void SomeTestMethod()
    {
        var mockIAppCache = new Mock<IAppCache>();
        var mockISeries = new Mock<ISeries>();

        ReportFR2 report = new ReportFR2(SeriesKey.FR2, mockIAppCache);
        DateTime resolvedDate = report.ResolveDate(mockISeries, DateTime.Now);

        //Assert.AreEqual("something", "something");

    }
4

1 回答 1

3

我相信你需要像这样通过模拟:

ReportFR2 report = new ReportFR2(SeriesKey.FR2, mockIAppCache.Object);
于 2013-06-21T23:13:38.553 回答