Rhino Mocks- 속성이 없을 때 속성 설정 확인
-
22-08-2019 - |
문제
속성이있는 경우 :
public class Fred
{
public string UserName
{
set
{
userName=value;
}
}
}
Rhino Mocks를 사용하여 어떻게 확인합니까?
fred= new Fred();
fred.UserName="Jim";
호출됩니다.
Expect.Call(mockFred.UserName).SetPropertyWithArgument("Jim");
컴파일하지 않습니다.
해결책
속성 세트에서 모든 것을 확인할 수 있어야합니다.
[TestClass]
public class FredTests
{
[TestMethod]
public void TestFred()
{
var mocker = new MockRepository();
var fredMock = mocker.DynamicMock<IFred>();
fredMock.UserName = "Name";
// the last call is actually to the set method of username
LastCall.IgnoreArguments();
mocker.ReplayAll();
fredMock.UserName = "Some Test that does this.";
mocker.VerifyAll();
}
}
public interface IFred
{
string UserName { set; }
}
다른 팁
public interface IFred
{
string UserName { set; }
}
[Test]
public void TestMethod1()
{
IFred fred = MockRepository.GenerateMock<IFred>();
fred.UserName = "Jim";
fred.AssertWasCalled(x => x.UserName = "Jim");
}
제휴하지 않습니다 StackOverflow