示例#1
0
        static void Main(string[] args)
        {
            int empId = 4;

            //Employee Personal Details
            EmpPersonalDetails personalDetails = new EmpPersonalDetails();

            Console.WriteLine("Year End bonus for Employee {0} is {1}",
                              personalDetails.GetEmployeeDetails(empId).Name, personalDetails.CalculateYearEndBonus(empId, 12));

            Console.WriteLine("Duration Worked by Employee {0} is {1}",
                              personalDetails.GetEmployeeDetails(empId).Name, personalDetails.GetDurationWorked(empId));

            //Employee PF
            EmpPfDetails pfDetails = new EmpPfDetails(new EmpPersonalDetails());

            Console.WriteLine("Employer Contribution for Employee {0} is {1}",
                              personalDetails.GetEmployeeDetails(empId).Name, pfDetails.GetPfEmployerControlSofar(empId));


            //Employee Benefits
            EmpBenefits empBenefits = new EmpBenefits(new EmpPersonalDetails());

            Console.WriteLine("Benefits of Employee with grade {0} are:",
                              personalDetails.GetEmployeeDetails(empId).Grade);

            foreach (var benefit in empBenefits.GetBasicBenefits(empId))
            {
                Console.Write(benefit + "  ");
            }



            Console.Read();
        }
示例#2
0
        public void Test1()
        {
            #region Commented

            //Video 1
            //Simple Moq
            //Arrange
            //var pfDetails = new EmpPfDetails(new EmpPersonalDetails());

            ////Act
            //var contrib = pfDetails.GetPfEmployerControlSofar(1);

            ////Assert
            //Assert.That(contrib, Is.EqualTo(3455), "Its not expected");

            //Arrange

            #endregion Commented

            var moqpfDetail = new Mock <IEmpPersonalDetails>();

            var pfDetails = new EmpPfDetails(moqpfDetail.Object);

            //Act
            pfDetails.GetPfEmployerControlSofar(It.IsAny <int>());

            //Assert
            moqpfDetail.Verify();
        }
示例#3
0
        public void TestMethodNUnit()
        {
            //Arrange
            var pfDetails = new EmpPfDetails(new EmpPersonalDetails());

            //Act
            var contrib = pfDetails.GetPfEmployerControlSofar(1);

            //Assert

            Assert.That(contrib, Is.EqualTo(3456), "Its not as expected");
        }
示例#4
0
        private static void Main(string[] args)
        {
            string returnValue = null;
            string name        = "Name";
            //XName environment = "SYSTare";
            //string reportName = "CognnosHPCReport";
            //string URL = GetCognosUrl(environment, reportName);
            //// Look for the name in the connectionStrings section.
            //ConnectionStringSettings settings =
            //    ConfigurationManager.ConnectionStrings[name];

            //// If found, return the connection string.
            //if (settings != null)
            //    returnValue = settings.ConnectionString;
            int  empId;
            char cont = 'Y';

            while (cont == 'Y')
            {
                empId = GetEmployeeIdFromUser();

                //Employee Personal Details
                EmpPersonalDetails personalDetails = new EmpPersonalDetails();

                Console.WriteLine("Year End bonus for Employee {0} is {1}",
                                  personalDetails.GetEmployeeDetails(empId).Name, personalDetails.CalculateYearEndBonus(empId, 12));

                Console.WriteLine("Duration Worked by Employee {0} is {1}",
                                  personalDetails.GetEmployeeDetails(empId).Name, personalDetails.GetDurationWorked(empId));

                //Employee PF
                EmpPfDetails pfDetails = new EmpPfDetails(new EmpPersonalDetails());

                Console.WriteLine("Employer Contribution for Employee {0} is {1}",
                                  personalDetails.GetEmployeeDetails(empId).Name, pfDetails.GetPfEmployerControlSofar(empId));

                //Employee Benefits
                EmpBenefits empBenefits = new EmpBenefits(new EmpPersonalDetails());
                Console.WriteLine("Benefits of Employee with grade {0} are:",
                                  personalDetails.GetEmployeeDetails(empId).Grade);

                foreach (var benefit in empBenefits.GetBasicBenefits(empId))
                {
                    Console.Write(benefit + "  ");
                }
                Console.WriteLine();
                Console.WriteLine("Press Y is you want to continue");
                cont = Convert.ToChar(Console.ReadLine());

                GenericDelegates dg = new GenericDelegates();
                int d = dg.UseGenericDelegates;
            }
        }
        public void TestMethodMoq()
        {
            //Arrange
            var moqPersonalDetails = new Mock <IEmpPersonalDetails>();

            var pfDetails = new EmpPfDetails(moqPersonalDetails.Object);

            //Act
            pfDetails.GetPfEmployerControlSofar(It.IsAny <int>());

            //Assert
            moqPersonalDetails.Verify();
        }
示例#6
0
        public void TestMethod1()
        {
            //Arrange
            var moqEmpPerDetail = new Mock <IEmpPersonalDetails>(MockBehavior.Strict);

            moqEmpPerDetail.Setup(x => x.GetDurationWorked(It.IsAny <int>())).Returns(20);
            moqEmpPerDetail.Setup(x => x.GetEmployeeSalary(It.IsAny <int>())).Returns(20);

            var pfEmpDetail = new EmpPfDetails(moqEmpPerDetail.Object);

            //Act
            pfEmpDetail.GetPfEmployerControlSofar(It.IsAny <int>());

            //Assert
            moqEmpPerDetail.Verify(x => x.GetDurationWorked(It.IsAny <int>()));
        }