Is there a reason to prefer to taunt an interface rather than a class with redefined members?

I have an external library used for messaging. In this library, I have an object with a name Channel.

This is the result after decompiling the dll:

public class Channel 
{
    public State CurrentState { get { /*Only for code compiling, the value depend on the TCP Connection state.*/return State.ERROR; } }
    public bool Send(string message)
    {
        //Some stuff with TCP connection.
        return true;
    }   

    public enum State
    {
      DISCONNECTED,
      CONNECTED,
      ERROR
    }
}

Now in my code, I use this Channelin the class to send messages, the class looks like this:

public class ClientConnection
{
    private Channel MyChannel;

    public ClientConnection(Channel channel)
    {
        MyChannel = channel;
    }

    public bool Send(string message)
    {
        bool result = false;
        if(MyChannel.CurrentState == Channel.State.CONNECTED)
        {
            result = MyChannel.Send(message);
        }
        return result;
    }
}

So, my goal is to test it, checking that the send method is being called, and checking that the arguments match my input. The problem here is that there is no interface, and the method is not virtual, so bullying is not possible directly.

What I did I created a wrapper with an override property and method:

public class ChannelWrapper
{
    private readonly Channel channel;
    public ChannelWrapper(Channel channel)
    {
        this.channel = channel;
    }
    public virtual Channel.State CurrentState { get { return channel.CurrentState; } }
    public virtual bool Send(string message)
    {
        return channel.Send(message);
    }
}

ClientConnection Channel ChannelWrapper .

, , Channel, ChannelWrapper, . .

- , ? ( ).

+4
1

, , , , , / .

, "// TCP-". . , Channel - ? , - -, . , ..

, , , " ", . , ; , , .

: ,

+3

All Articles