示例#1
0
        public void GetPermEmployeeTest_WithoutPay()
        {
            //Arrange
            var permEmpMock = new List <PermEmployeeEntity>
            {
                new PermEmployeeEntity {
                    Id = 1, HoursWorked = 1, Name = "Name1", PayRate = 1
                },
                new PermEmployeeEntity {
                    Id = 2, HoursWorked = 2, Name = "Name2", PayRate = 2
                }
            };

            MockPermEmpRep.Setup(x => x.Get()).Returns(permEmpMock);
            MockUnitofWork.SetupGet(x => x.PermEmpRepository).Returns(MockPermEmpRep.Object);
            empOps = new EmpOperations(MockUnitofWork.Object);

            //Act
            var res = empOps.GetPermEmployees(false).ToList();

            //Assert
            Assert.IsNotNull(res);
            Assert.AreEqual(res.Count, 2);
            Assert.AreEqual(res[0].Id, 1);
            Assert.AreEqual(res[0].Name, "Name1");
            Assert.AreEqual(res[0].HoursWorked, 1);
            Assert.AreEqual(res[0].PayRate, 1);
            Assert.AreEqual(res[0].TotalPay, 0);
        }
示例#2
0
        public void AddPermEmployeeTest()
        {
            //Arrange
            MockUnitofWork.SetupGet(x => x.PermEmpRepository).Returns(MockPermEmpRep.Object);
            empOps = new EmpOperations(MockUnitofWork.Object);

            //Act
            var res = empOps.AddPermEmployee(new PermEmployee());

            //Assert
            MockPermEmpRep.Verify(x => x.Add(It.IsAny <PermEmployeeEntity>()), Times.Exactly(1));
            MockUnitofWork.Verify(x => x.SaveChanges(), Times.Exactly(1));
            Assert.IsTrue(res);
        }
示例#3
0
        public void AddEmployeeTest_AddFails()
        {
            //Arrange
            MockEmpRep.Setup(x => x.Add(It.IsAny <EmployeeEntity>())).Throws(new Exception());
            MockUnitofWork.SetupGet(x => x.EmpRepository).Returns(MockEmpRep.Object);
            empOps = new EmpOperations(MockUnitofWork.Object);

            //Act
            var res = empOps.AddEmployee(new Employee());

            //Assert
            MockEmpRep.Verify(x => x.Add(It.IsAny <EmployeeEntity>()), Times.Exactly(1));
            MockUnitofWork.Verify(x => x.SaveChanges(), Times.Exactly(0));
            Assert.IsFalse(res);
        }