I am trying to mock using a method call using typeMock. I have mocked method in different cases but every time I am getting the same result. Following is code:
[TestFixture]
public class HomeControllerSpec
{
User _fakeUser;
ProfileSettingsBL _profileSettingBL = null;
[SetUp]
public void SetUp()
{
// Inital setup
}
[TestCase]
public void DisconnectOutlookCalendarForUserRegisterWithEmail()
{
_fakeUser = new User();
_fakeUser.LoginType = 4; // This is be different in each case
Isolate.WhenCalled(() => _profileSettingBL.RetrieveUserProfile()).WillReturn(_fakeUser);
HomeController ctrl = new HomeController();
var result = ctrl.Disconnect();
Assert.IsTrue(result.Content);
}
[TestCase]
public void DisconnectOutlookCalendarForUserRegisterWithName()
{
_fakeUser = new User();
_fakeUser.LoginType = 5; // This is be different in each case
Isolate.WhenCalled(() => _profileSettingBL.RetrieveUserProfile()).WillReturn(_fakeUser);
HomeController ctrl = new HomeController();
var result = ctrl.Disconnect();
Assert.IsTrue(result.Content);
}
}
When different test case calling Disconnect
method of HomeController I am getting _fakeUser.LoginType == 4
always. But when I am removing one of test case both cases running perfectly.
Any Idea?
答案 0 :(得分:1)
也许您可以尝试使用class node(object):
def __init__(self,value):
self.data=value
self.left=None
self.right=None
def insert(Node,value):
if Node is None:
Node=node(value)
else:
if value<Node.data:
## if Node.left is None: Node.left=node(value)
## else: insert(Node.left,value)
insert(Node.left,value)
else:
## if Node.left is None: Node.left=node(value)
## else: insert(Node.left,value)
insert(Node.right,value)
属性?
它指示Typemock Isolator在测试完成后清理测试结果。