lundi 8 août 2016

Trying with Mocking in Unit test case

I am trying with Simple Multiplication application ,

public virtual int Multi(int a, int b)
        {
            return a * b;
        }

I am trying to Mock it using Moq. But in the

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            int a = 5;
            int b = 10;
            Mock<WebForm1> Titi = new Mock<WebForm1>();
            // WebForm1 obj = new WebForm1();
            //int  Real=  obj.Multi(a, b);
              Titi.Setup(x => x.data()).Returns(true);
            Titi.CallBase = true;
       // var data= Titi.Setup(x => x.Multi(a, b)).Returns(50);



            Assert.AreEqual(true, Titi.Object);
            //Assert.AreEqual(50, Titi.Object); 




        }
    }
}

Where as in the Mocking outut I am getting

Assert.AreEqual failed. Expected:<True (System.Boolean)>. Actual:<Castle.Proxies.WebForm1Proxy (Castle.Proxies.WebForm1Proxy)>

It means the actual & Expected are not matching, But why I am getting this error? where as it's a simple logic.

Aucun commentaire:

Enregistrer un commentaire