public async Task DeleteUserSendsUserQueryWithCorrectUserId() { var mediator = new Mock<IMediator>(); const string userId = "foo_id"; mediator.Setup(x => x.SendAsync(It.Is<UserQuery>(q => q.UserId == userId))).ReturnsAsync(new EditUserModel()); var controller = new SiteController(null, null, mediator.Object); await controller.DeleteUser(userId); mediator.Verify(m =>m.SendAsync(It.Is<UserQuery>(q =>q.UserId == userId)), Times.Once); }
public async Task DeleteUserReturnsTheCorrectViewModel() { var mediator = new Mock<IMediator>(); const string userId = "foo_id"; mediator.Setup(x => x.SendAsync(It.IsAny<UserQuery>())).ReturnsAsync(new EditUserModel()); var controller = new SiteController(null, null, mediator.Object); var result = await controller.DeleteUser(userId); var model = ((ViewResult)result).ViewData.Model as DeleteUserModel; Assert.Equal(model.UserId, userId); Assert.IsType<DeleteUserModel>(model); }