public void IsPfEligibleTest_SalaryLessThan4000_ReturnsFalse(int Salary)
        {
            var moqPersonalDetails = new Mock <IEmpPersonalDetails>();

            moqPersonalDetails.Setup(x => x.GetEmployeeSalary(It.IsAny <int>())).Returns(Salary);
            EmpPfDetails pfDetails = new EmpPfDetails(moqPersonalDetails.Object);

            var Result = pfDetails.IsPfEligible(0);

            Assert.IsFalse(Result);
        }
示例#2
0
        public void TestMethodTimes()
        {
            //Arrange
            var moqPersonaldetail = new Mock <IEmpPersonalDetails>();
            var pfDetail          = new EmpPfDetails(moqPersonaldetail.Object);

            //Act
            pfDetail.IsPfEligible(It.IsAny <int>());

            //Assert
            moqPersonaldetail.Verify(x => x.GetEmployeeSalary(It.IsAny <int>()), Times.Exactly(1));
        }
示例#3
0
        public void TestMethodReturnValue()
        {
            //Arrange
            var moqPersonalDetails = new Mock <IEmpPersonalDetails>();

            moqPersonalDetails.Setup(x => x.GetEmployeeSalary(It.IsAny <int>())).Returns(() => 5000);

            var pfDetails = new EmpPfDetails(moqPersonalDetails.Object);

            //Act
            var isEligible = pfDetails.IsPfEligible(It.IsAny <int>());

            //Assert
            Assert.IsTrue(isEligible, "Should be true");
        }