Ok,
I have two tests, one does not mock, and works, one mocks and fails with the following:
TearDown : TypeMock.VerifyException :
TypeMock Verification: Method TypeMockTests.MainClass.GetSquare() has 1 more expected calls
--TearDown
at TypeMock.Mock.Verify()
at TypeMock.Expectations.Verify()
at TypeMock.MockManager.Verify()
at TypeMockTests.Test.MainClassTests.TearDown() in c:documents and settings
obpmy documentsisual studio projects ypemocktests estmainclasstests.cs:line 45
The thing is, I am pulling my hair out as to see why
My simple class is this
using System;
namespace TypeMockTests
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class MainClass
{
public MainClass()
{
//
// TODO: Add constructor logic here
//
}
public int GetSquare(int nNumber)
{
return (int)(nNumber*nNumber);
}
}
}
My tests are as follows, and I get this "TypeMock Verification: Method TypeMockTests.MainClass.GetSquare() has 1 more expected calls" error, and cannot work out why, please help !
using System;
using NUnit.Framework;
using TypeMock;
namespace TypeMockTests.Test
{
/// <summary>
/// Summary description for MainClassTests.
/// </summary>
[TestFixture]
public class MainClassTests
{
[SetUp]
public void SetUp()
{
MockManager.Init();
}
[Test]
public void TestTheGetSquareFunctionWithCorrectValues()
{
MainClass rob = new MainClass();
Assert.AreEqual(4,rob.GetSquare(2));
}
[Test]
public void TestTheMockedClass()
{
Mock myMock = MockManager.Mock(typeof(MainClass));
myMock.ExpectAndReturn("GetSquare",4);
MainClass myClass = new MainClass();
Assert.AreEqual(4,myClass.GetSquare(2));
}
[TearDown]
public void TearDown()
{
MockManager.Verify();
}
}
}