public void Block_UnapprovedCompanyShouldRedirectToAllCompanies()
        {
            //Arrange
            var controller = new AdminCompaniesController(this.companyService.Object);

            this.companyService.Setup(c => c.CompanyExists(It.IsAny <string>()))
            .Returns(true);

            this.companyService.Setup(c => c.ChangeStatus(It.IsAny <string>()))
            .Returns(false);

            this.PrepareTempData();

            controller.TempData = this.tempData.Object;

            //Act
            var result = controller.Block(CompanyId, CompanyStatus.All, 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.BlockCompanyUnavailable, CompanyId));
        }
        public void UnBlock_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.ChangeStatus(It.IsAny <string>()))
            .Returns(true);

            this.companyService.Setup(c => c.GetCompanyName(It.IsAny <string>()))
            .Returns(CompanyName);

            this.companyService.Setup(c => c.GetBlockStatus(It.IsAny <string>()))
            .Returns(CompanyStatusUnblocked);

            this.PrepareTempData();

            controller.TempData = this.tempData.Object;

            //Act
            var result = controller.Block(CompanyId, CompanyStatus.All, 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.All);
            this.customMessage.Should().Be(string.Format(WebConstants.Message.CompanyStatusChanged, CompanyName, CompanyStatusUnblocked));
        }
        public void Block_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.Block(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));
        }