public async Task DeleteGetReturnsNotFoundResultWhenViewModelIsNull() { var sut = new OrganizationController(Mock.Of<IMediator>(), null); var result = await sut.Delete(It.IsAny<int>()); Assert.IsType<NotFoundResult>(result); }
public async Task DeleteGetAssignsCorrectTitleToViewModel() { var viewModel = new DeleteViewModel { Title = "Title" }; var mediator = new Mock<IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny<DeleteQuery>())).ReturnsAsync(viewModel); var sut = new OrganizationController(mediator.Object, null); var result = await sut.Delete(It.IsAny<int>()) as ViewResult; var modelResult = result.Model as DeleteViewModel; Assert.Equal(modelResult.Title, $"Delete {viewModel.Name}"); }
public async Task DeleteGetSendsDeleteQueryWithTheCorrectOrgId() { const int orgId = 1; var mediator = new Mock<IMediator>(); var sut = new OrganizationController(mediator.Object, null); await sut.Delete(orgId); mediator.Verify(x => x.SendAsync(It.Is<DeleteQuery>(y => y.OrgId == orgId)), Times.Once); }