-1
我有一個註冊頁面,這使得下面如何嘲笑我的工作對象
var registeredAccount = await _accountServiceChannel.RegisterAsync(accountContract);
我怎麼能嘲笑返回的對象異步調用的演出,我試圖構建像我展示如下
[Test]
public void Display_Validate_Account_Page_On_Successful_Registration()
{
//arrange
var businessContract = Mapper.Map<BusinessViewModel, BusinessContract>(_userRegisterationViewModel.Business);
var userContract = Mapper.Map<UserViewModel, UserContract>(_userRegisterationViewModel.User);
var accountContract = new AccountContract()
{
Business = businessContract,
User = userContract
};
_mockAccountContract
.Setup(contract => contract.Result.Value.Business)
.Returns(accountContract.Business);
_mockAccountContract
.Setup(contract => contract.Result.Value.User)
.Returns(accountContract.User);
_mockAccountServiceChannel
.Setup(svc => svc.RegisterAsync(accountContract))
.Returns(_mockAccountContract.Object);
//act
var result = (RedirectToRouteResult)_registerController.Register(_userRegisterationViewModel).Result;
//assert
Assert.That(result.RouteValues["action"], Is.EqualTo("ValidateAccount"));
}
但我認爲這是行不通的,因爲我想設置一個只有get屬性的對象。
如果起訂量,你使用甚至不會編譯 –
什麼版本? – Nkosi
你在哪裏得到錯誤? – Nkosi