public void ReturnCreateEmployeePaycheckViewModel_WhenActionIsCalled()
        {
            // Arrange
            var mapService          = new Mock <IMapService>();
            var employeeService     = new Mock <IEmployeeService>();
            var paycheckService     = new Mock <IEmployeePaycheckService>();
            var payrollCalculations = new Mock <Payroll>();

            var id = 5;

            Employee mockedEmployee = new FakeEmployee()
            {
                Id         = id,
                FirstName  = "Alexander",
                MiddleName = "Petrov",
                LastName   = "Vasilev",
                PersonalId = "8010107070"
            };

            EmployeePaycheck mockedPaycheck = new FakeEmployeePaycheck()
            {
                Id         = 1,
                EmployeeId = id,
                Employee   = mockedEmployee
            };

            employeeService.Setup(x => x.GetById(id)).Returns(mockedEmployee).Verifiable();

            var laborContractModel = new CreateEmployeePaycheckViewModel();

            mapService.Setup(x => x.Map <CreateEmployeePaycheckViewModel>(mockedPaycheck)).Returns(laborContractModel).Verifiable();

            // Act
            LaborContractController laborController = new LaborContractController(mapService.Object, employeeService.Object, paycheckService.Object, payrollCalculations.Object);

            laborController.ModelState.AddModelError("invalid", "Invalid");

            var result = laborController.CreateLaborContract(id, mockedPaycheck) as ViewResult;

            // Assert
            Assert.IsInstanceOf <ViewResult>(result);
            Assert.AreEqual(laborContractModel, result.Model);
        }
        public void ReturnCreateLaborContractViewModel_WhenModelStateIsNotValid()
        {
            // Arrange
            var mapService          = new Mock <IMapService>();
            var employeeService     = new Mock <IEmployeeService>();
            var paycheckService     = new Mock <IEmployeePaycheckService>();
            var payrollCalculations = new Mock <Payroll>();

            var id = 5;
            var laborContractModel = new Mock <PreviewEmployeePaycheckViewModel>();

            laborContractModel.SetupProperty(x => x.GrossSalary, 1000);
            laborContractModel.SetupProperty(x => x.GrossFixedBonus, 100);
            laborContractModel.SetupProperty(x => x.GrossNonFixedBonus, 100);

            Employee mockedEmployee = new FakeEmployee()
            {
                Id         = id,
                FirstName  = "Alexander",
                MiddleName = "Petrov",
                LastName   = "Vasilev",
                PersonalId = "8010107070"
            };

            employeeService.Setup(x => x.GetById(id)).Returns(mockedEmployee).Verifiable();

            // Act
            LaborContractController laborController = new LaborContractController(mapService.Object, employeeService.Object, paycheckService.Object, payrollCalculations.Object);

            laborController.ModelState.AddModelError("invalid", "Invalid");

            var result = laborController.CreateLaborContract(id, laborContractModel.Object) as ViewResult;

            // Assert
            Assert.IsInstanceOf <ViewResult>(result);
            Assert.AreEqual(laborContractModel.Object, result.Model);
        }