0

VS 2012, .NET 4.0, Moq.4.1.1308.2321, Debug configuration. My static class creates Moq object like this:

public static Mock<IQuoteStorage> MakeMoq()
{
    var moq = new Mock<IQuoteStorage>();
    moq.Setup(s => s.GetTickersHistoryStarts()).Returns<Dictionary<string, DateSpan>>(
        delegate
        {
            return new Dictionary<string, DateSpan>();                        
        });

    moq.Setup(s => s.GetMinuteCandlesPacked(It.IsAny<string>(), It.IsAny<DateTime>(), It.IsAny<DateTime>())).Returns((string ticker, DateTime start, DateTime end) =>
        {
            return new PackedCandleStream(new List<CandleDataPacked>(), false);                      
        });

    return moq;            
}

I store this MakeMoq().Object in a static variable implementer of a class named QuoteStorageProxy. Then I use this QuoteStorageProxy - make an instance of it and call some method. In this method I check

if (implementer == null) // ReferenceEquals do the same
    throw new Exception("...");

I do not see any reason for the implementer (Moq.Object) being null. VS debugger shows its fields! In Immediate I check "implementer == null" and get false. Still I get the exception!

How can it be null and not null at the same time?

4

0 に答える 0