سؤال

When I create my moq mock and try to pass it into my class constructor I get this message: Argument type Moq.Mock<...mockIAppCache> is not assingable to paramter type 'IAppCache'. I included the library and I can find the reference to Mock() ok. Am I missing something here?

    [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");

    }
هل كانت مفيدة؟

المحلول

I believe you need to pass the mock like this:

ReportFR2 report = new ReportFR2(SeriesKey.FR2, mockIAppCache.Object);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top