Beispiel #1
0
        public void Test3()
        {
            #region Commented

            //Arrange
            //var moqpfDetail = new Mock<IEmpPersonalDetails>();

            //moqpfDetail.Setup(x => x.GetDurationWorked(It.IsAny<int>()));

            //var pfDetails = new EmpPfDetails(moqpfDetail.Object);

            ////Act
            //pfDetails.GetPfEmployerControlSofar(1);

            ////Assert
            //moqpfDetail.Verify(x => x.GetDurationWorked(It.IsAny<int>()),
            //    Times.Exactly(1));

            //Number of times being called

            #endregion Commented

            List <Employee> employees = new List <Employee>
            {
                new Employee
                {
                    EmpId          = 5,
                    DurationWorked = 20,
                    Grade          = 3,
                    Name           = "Steve",
                    Salary         = 9000
                },
                new Employee
                {
                    EmpId          = 6,
                    DurationWorked = 30,
                    Grade          = 4,
                    Name           = "Johnson",
                    Salary         = 8000
                }
            };

            //Arrange
            var empPersonalDetail = new Mock <IEmpPersonalDetails>();

            var empDetails = new EmployeesDetails(empPersonalDetail.Object);

            empDetails.GetHigherGradeEmployee(employees);

            empPersonalDetail.Verify(x => x.GetEmployeeDetails(It.IsAny <int>()), Times.Exactly(2));
        }
Beispiel #2
0
        public void TestMethodTimes2()
        {
            List <Employee> employees = new List <Employee>()
            {
                new Employee()
                {
                    EmpId          = 1,
                    Name           = "Karthik",
                    Salary         = 4000,
                    DurationWorked = 24,
                    Grade          = 1,
                    Email          = "*****@*****.**"
                },

                new Employee()
                {
                    EmpId          = 2,
                    Name           = "Prashanth",
                    Salary         = 7000,
                    DurationWorked = 30,
                    Grade          = 2,
                    Email          = "*****@*****.**"
                }
            };


            //Arrange
            var moqPersonaldetail = new Mock <IEmpPersonalDetails>();
            var empDetail         = new EmployeesDetails(moqPersonaldetail.Object);

            //Act
            empDetail.GetHigherGradeEmployee(employees);

            //Assert

            moqPersonaldetail.Verify(x => x.GetEmployeeDetails(It.IsAny <int>()), Times.Exactly(2));
        }