Question

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

    }
Était-ce utile?

La solution

I believe you need to pass the mock like this:

ReportFR2 report = new ReportFR2(SeriesKey.FR2, mockIAppCache.Object);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top