Можно ли это поиздеваться с Moq?

Я работаю над издевательством над некоторыми внешними зависимостями, и у меня возникли проблемы с одним сторонним классом, который принимает в своем конструкторе экземпляр другого стороннего класса. Надеюсь, Сообщество может дать мне некоторое руководство.

Я хочу создать макет экземпляраSomeRelatedLibraryClass который принимает в своем конструкторе фиктивный экземплярSomeLibraryClass, Как я могу издеватьсяSomeRelatedLibraryClass сюда?

The repo code...

Вот метод Main, который я использую в своем тестовом консольном приложении.

public static void Main()
{
    try
    {
        SomeLibraryClass slc = new SomeLibraryClass("direct to 3rd party");
        slc.WriteMessage("3rd party message");
        Console.WriteLine();

        MyClass mc = new MyClass("through myclass");
        mc.WriteMessage("myclass message");
        Console.WriteLine();

        Mock<MyClass> mockMc = new Mock<MyClass>("mock myclass");
        mockMc.Setup(i => i.WriteMessage(It.IsAny<string>()))
            .Callback((string message) => Console.WriteLine(string.Concat("Mock SomeLibraryClass WriteMessage: ", message)));

        mockMc.Object.WriteMessage("mock message");
        Console.WriteLine();
    }
    catch (Exception e)
    {
        string error = string.Format("---\nThe following error occurred while executing the snippet:\n{0}\n---", e.ToString());
        Console.WriteLine(error);
    }
    finally
    {
        Console.Write("Press any key to continue...");
        Console.ReadKey();
    }
}

Вот класс, который я использовал, чтобы обернуть один сторонний класс и позволить ему быть Moq 'd:

public class MyClass
{
    private SomeLibraryClass _SLC;

    public MyClass(string constructMsg)
    {
        _SLC = new SomeLibraryClass(constructMsg);
    }

    public virtual void WriteMessage(string message)
    {
        _SLC.WriteMessage(message);
    }
}

Вот два примера сторонних классов, с которыми я работаю (YOU CAN NOT EDIT THESE):

public class SomeLibraryClass
{
    public SomeLibraryClass(string constructMsg)
    {
        Console.WriteLine(string.Concat("SomeLibraryClass Constructor: ", constructMsg));
    }

    public void WriteMessage(string message)
    {
        Console.WriteLine(string.Concat("SomeLibraryClass WriteMessage: ", message));
    }
}

public class SomeRelatedLibraryClass
{
    public SomeRelatedLibraryClass(SomeLibraryClass slc)
    {
        //do nothing
    }

    public void WriteMessage(string message)
    {
        Console.WriteLine(string.Concat("SomeRelatedLibraryClass WriteMessage: ", message));
    }
}

Ответы на вопрос(2)

Ваш ответ на вопрос