samedi 3 octobre 2015

Error on testing method

My working method, which need to be tested:

using TCatSysManagerLib; // for TcSysManager
public static int ProcessPositionBias(TcSysManager tcsm)
{
    // method body here
    return 0;
}

Now in Test Unit I tried to simulate TcSysManager, because it works with hardware, which is not available during tests and I can't even use it:

namespace TestClient
{
    [TestClass]
    public class UnitTestClient
    {
        [TestMethod]
        public void TestVersion()
        {
            Mock<TcSysManager> tcsm = new Mock<TcSysManager>();

            int r = ClientProgram.ProcessPositionBias(tcsm.Object); // errors here

        }
    }

    public TcSysManager
    {
        // I promise to implement some methods which I use in my app
    }
}

Basically compiler complains about 3 things:

Error 1 The type 'TCatSysManagerLib.TcSysManager' is defined in an assembly that is not referenced. You must add a reference to assembly 'Interop.TCatSysManagerLib, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'.

Error 2 The best overloaded method match for 'Client.ClientProgram.ProcessPositionBias(TCatSysManagerLib.TcSysManager)' has some invalid arguments

Error 3 Argument 1: cannot convert from 'TestClient.TcSysManager' to 'TCatSysManagerLib.TcSysManager'

Aucun commentaire:

Enregistrer un commentaire