public void Approve_WithValidDataShouldRedirectToAllCompanies() { //Arrange var controller = new AdminCompaniesController(this.companyService.Object); this.companyService.Setup(c => c.CompanyExists(It.IsAny <string>())) .Returns(true); this.companyService.Setup(c => c.Approve(It.IsAny <string>())) .Returns(true); this.companyService.Setup(c => c.GetCompanyName(It.IsAny <string>())) .Returns(CompanyName); this.PrepareTempData(); controller.TempData = this.tempData.Object; //Act var result = controller.Approve(CompanyId, CompanyStatus.Unapproved, MinPageSize); //Assert result.Should().BeOfType <RedirectToActionResult>(); var model = result.As <RedirectToActionResult>(); model.ActionName.Should().Be(WebConstants.Action.AdminAllCompanies); model.RouteValues.Keys.Should().Contain(RouteValueKeyPage); model.RouteValues.Values.Should().Contain(MinPageSize); model.RouteValues.Keys.Should().Contain(RouteValueKeyAdminCompaniesFilter); model.RouteValues.Values.Should().Contain(CompanyStatus.Unapproved); this.customMessage.Should().Be(string.Format(WebConstants.Message.CompanyApproved, CompanyName)); }
public void Approve_WithInvalidCompanyIdShouldRedirectToAllCompanies(string companyId) { //Arrange var controller = new AdminCompaniesController(this.companyService.Object); this.companyService.Setup(c => c.CompanyExists(It.IsAny <string>())) .Returns(false); this.PrepareTempData(); controller.TempData = this.tempData.Object; //Act var result = controller.Approve(companyId, CompanyStatus.Unapproved, MinPageSize); //Assert result.Should().BeOfType <RedirectToActionResult>(); var model = result.As <RedirectToActionResult>(); model.ActionName.Should().Be(WebConstants.Action.AdminAllCompanies); this.customMessage.Should().Be(string.Format(WebConstants.Message.NonExistingEntity, nameof(WebConstants.Entity.Company), companyId)); }