Moq C #, встроенный в класс

Я пытаюсь имитировать класс SearchResultCollection. Однако, когда я пытаюсь перехватить вызов геттера PropertiesLoaded, мой тест выдает исключение:

System.NotSupportedException: Invalid setup on a non-virtual (overridable in VB) member: x => x.PropertiesLoaded

Мой код:

Mock<SearchResultCollection> searchResultMock = new Mock<SearchResultCollection>();

// Set up collection that will be returned
string[] tempData = { "one", "two" };
searchResultMock.SetupGet(x => x.PropertiesLoaded).Returns(tempData);

Кто-нибудь успешно высмеивал такой класс? Рассматриваемое свойство имеет только геттер и не является виртуальным.

    //
    // Summary:
    //     Gets the System.DirectoryServices.DirectorySearcher properties that were
    //     specified before the search was executed.
    //
    // Returns:
    //     An array of type System.String that contains the properties that were specified
    //     in the System.DirectoryServices.DirectorySearcher.PropertiesToLoad property
    //     collection before the search was executed.
    public string[] PropertiesLoaded { get; }
6
задан MarkP 26 October 2011 в 17:42
поделиться