public void Given_valid_viewmodel_When_delete_company_default_Then_should_call_correct_methods()
        {
            // Given
            var target = CreateCompanyDefaultsController();

            var viewModel = new DeleteCompanyDefaultViewModel()
            {
                CompanyId = 100,
                CompanyDefaultId = 3,
                CompanyDefaultType = "Hazards",
            };

            var mockDeleteTask = new Mock<ICompanyDefaultDeleteTask>();
            _companyDefaultsTaskFactory
                .Setup(x => x.CreateMarkForDeletedTask(viewModel.CompanyDefaultType))
                .Returns(mockDeleteTask.Object);

            var userId = target.CurrentUser.UserId;
           
            // When
            target.DeleteCompanyDefault(viewModel);

            // Then
            _companyDefaultsTaskFactory.VerifyAll();
            mockDeleteTask.Verify(y=>y.Execute(viewModel.CompanyDefaultId, viewModel.CompanyId, userId), Times.Once());
        }
        public void Given_default_deleted_successfully_Then_should_return_correct_result()
        {
             // Given
            var target = CreateCompanyDefaultsController();

            var viewModel = new DeleteCompanyDefaultViewModel()
            {
                CompanyId = 100,
                CompanyDefaultId = 3,
                CompanyDefaultType = "Hazards",
            };

            var mockDeleteTask = new Mock<ICompanyDefaultDeleteTask>();
            _companyDefaultsTaskFactory
                .Setup(x => x.CreateMarkForDeletedTask(viewModel.CompanyDefaultType))
                .Returns(mockDeleteTask.Object);

            // When
            var result = target.DeleteCompanyDefault(viewModel) as JsonResult;

            // Then
            Assert.That(result.Data.ToString(), Contains.Substring("{ Id = 3, Success = True }"));
        }
 public JsonResult DeleteCompanyDefault(DeleteCompanyDefaultViewModel viewModel)
 {
     var deleteTask = _companyDefaultsTaskFactory.CreateMarkForDeletedTask(viewModel.CompanyDefaultType);
     deleteTask.Execute(viewModel.CompanyDefaultId, viewModel.CompanyId, CurrentUser.UserId);
     return Json(new { Id = viewModel.CompanyDefaultId, Success = true });
 }