public void Create(RemunerationBill bill)
        {
            Guard.WhenArgument(bill, "bill").IsNull().Throw();

            this.remunerationBills.Add(bill);
            this.remunerationBills.SaveChanges();
        }
Exemplo n.º 2
0
        public void WhenConstructorIsInvoked_ShouldSetInstanceOfRemunerationBillCorrectly()
        {
            // Arrange & Act
            var bill = new RemunerationBill();

            // Assert
            Assert.IsInstanceOf(typeof(RemunerationBill), bill);
        }
Exemplo n.º 3
0
        public void WhenConstructorIsInvoked_ShouldNotSet_PersonalInsuranceProperty()
        {
            // Arrange & Act
            var bill = new RemunerationBill();

            // Assert
            Assert.AreEqual(0.0m, bill.PersonalInsurance);
        }
        public void UpdateById(int id, RemunerationBill updateBill)
        {
            var billToUpdate = this.remunerationBills.GetById(id);

            billToUpdate.EmployeeId = updateBill.EmployeeId;

            this.remunerationBills.SaveChanges();
        }
Exemplo n.º 5
0
        public void WhenConstructorIsInvoked_ShouldNotSet_IncomeTaxProperty()
        {
            // Arrange & Act
            var bill = new RemunerationBill();

            // Assert
            Assert.AreEqual(0.0m, bill.IncomeTax);
        }
Exemplo n.º 6
0
        public void WhenConstructorIsInvoked_ShouldNotSet_SocialSecurityIncomeProperty()
        {
            // Arrange & Act
            var bill = new RemunerationBill();

            // Assert
            Assert.AreEqual(0.0m, bill.SocialSecurityIncome);
        }
Exemplo n.º 7
0
        public void WhenConstructorIsInvoked_ShouldNotSet_GrossSalaryProperty()
        {
            // Arrange & Act
            var bill = new RemunerationBill();

            // Assert
            Assert.AreEqual(0.0m, bill.GrossSalary);
        }
        public ActionResult CreateNonLaborContract(int id, RemunerationBill remunerationBill)
        {
            var employee = this.employeeService.GetById(id);

            remunerationBill.EmployeeId = id;
            remunerationBill.Employee   = employee;
            var nonLaborContractModel = this.mapService.Map <CreateRemunerationBillViewModel>(remunerationBill);

            nonLaborContractModel.CreatedDate = DateTime.Now;
            return(View(nonLaborContractModel));
        }
        public ActionResult Delete(int id, RemunerationBill bill)
        {
            bill = this.remunerationBillService.GetById(id);
            if (bill == null)
            {
                return(HttpNotFound());
            }

            var nonLaborContractModel = this.mapService.Map <PreviewRemunerationBillViewModel>(bill);

            return(View(nonLaborContractModel));
        }
Exemplo n.º 10
0
        public ActionResult Delete(int id, RemunerationBill bill)
        {
            bill = this.billService.GetById(id);
            if (bill == null)
            {
                return(HttpNotFound());
            }

            var billViewModel = this.mapService.Map <BillViewModel>(bill);

            return(View(billViewModel));
        }
        public void PropertiesWithRequiredAttribute_ShouldReturnTrue(string propertyName)
        {
            var bill = new RemunerationBill();

            var result = bill.GetType()
                         .GetProperty(propertyName)
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(RequiredAttribute))
                         .Any();

            Assert.IsTrue(result);
        }
        public void SocialSecurityIncomeProperty_WithRangeAttribute_MustReturnMaxSocialSecurityIncomeValue(string propertyName)
        {
            var bill = new RemunerationBill();

            var result = bill.GetType()
                         .GetProperty(SocialSecurityIncomeProperty)
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(System.ComponentModel.DataAnnotations.RangeAttribute))
                         .Select(x => (System.ComponentModel.DataAnnotations.RangeAttribute)x)
                         .FirstOrDefault();

            Assert.AreEqual(ValidationConstants.MaxSocialSecurityIncome, result.Maximum);
        }
        public ActionResult Edit(int id, RemunerationBill bill)
        {
            bill = this.remunerationBillService.GetById(id);
            if (bill == null)
            {
                return(HttpNotFound());
            }
            var nonLaborContractModel = this.mapService.Map <PreviewRemunerationBillViewModel>(bill);
            var employee = this.employeeService.GetById(bill.EmployeeId);

            nonLaborContractModel.EmployeeId       = employee.Id;
            nonLaborContractModel.EmployeeFullName = employee.FirstName + " " + employee.MiddleName + " " + employee.LastName;

            return(View(nonLaborContractModel));
        }
Exemplo n.º 14
0
        public void PropertyWithForeignKeyAttribute_ShouldReturnTrue()
        {
            // Arrange
            var bill = new RemunerationBill();

            // Act
            var result = bill.GetType()
                         .GetProperty("Employee")
                         .GetCustomAttributes(false)
                         .Where(x => x.GetType() == typeof(ForeignKeyAttribute))
                         .Any();

            // Assert
            Assert.IsTrue(result);
        }
Exemplo n.º 15
0
        public void ReturnHttpNotFoundResult_WhenEmployeeIsNull()
        {
            // Arrange
            var mapService          = new Mock <IMapService>();
            var employeeService     = new Mock <IEmployeeService>();
            var billService         = new Mock <IRemunerationBillService>();
            var payrollCalculations = new Mock <Payroll>();

            var id = 5;
            RemunerationBill nonLaborContractModel = null;

            billService.Setup(x => x.GetById(id)).Returns(nonLaborContractModel).Verifiable();

            // Act
            var nonLaborController = new NonLaborContractController(mapService.Object, employeeService.Object, billService.Object, payrollCalculations.Object);

            // Assert
            Assert.IsInstanceOf <HttpNotFoundResult>(nonLaborController.Delete(id, nonLaborContractModel));
        }
Exemplo n.º 16
0
        public void HttpGet_ReturnHttpNotFoundResult_WhenPaycheckIsNull()
        {
            // Arrange
            var mapService          = new Mock <IMapService>();
            var employeeService     = new Mock <IEmployeeService>();
            var billService         = new Mock <IRemunerationBillService>();
            var payrollCalculations = new Mock <Payroll>();

            var id = 5;
            var nonLaborContractModel = new Mock <PreviewRemunerationBillViewModel>();

            RemunerationBill mockedBill = null;

            billService.Setup(x => x.GetById(id)).Returns(mockedBill).Verifiable();

            // Act & Assert
            var nonLaborController = new NonLaborContractController(mapService.Object, employeeService.Object, billService.Object, payrollCalculations.Object);

            Assert.IsInstanceOf <HttpNotFoundResult>(nonLaborController.Edit(id, mockedBill));
        }
 public void UpdateById(int id, RemunerationBill updateBill)
 {
     this.remunerationBills.Update(updateBill);
     this.remunerationBills.SaveChanges();
 }
        public void WhenConstructorIsInvoked_ShouldNotSet_NetWageProperty()
        {
            var bill = new RemunerationBill();

            Assert.AreEqual(0.0m, bill.NetWage);
        }
 public void Create(RemunerationBill bill)
 {
     this.remunerationBills.Add(bill);
     this.remunerationBills.SaveChanges();
 }
        public void WhenConstructorIsInvoked_ShouldNotSet_IdProperty()
        {
            var bill = new RemunerationBill();

            Assert.AreEqual(0, bill.Id);
        }