コード例 #1
0
        public void GetByUniqueID_ReturnsEmployeeInformationObject()
        {
            //Arrange

            EmployeeInformation ExcpectedResult = Utility.ParseJSONArray <EmployeeInformation>(jsonStr);

            _employeeData.Setup(x => x.GetByUniqueID("2AC72CB1-2BE1-4E79-BBCB-5763ECB810CB")).Returns(ExcpectedResult);

            var controller = new EmployeeDataController(_employeeData.Object);

            //Act
            var Result = (OkObjectResult)controller.Get("2AC72CB1-2BE1-4E79-BBCB-5763ECB810CB");
            EmployeeInformation ActualResult = Utility.ParseJSONArray <EmployeeInformation>(Result.Value.ToString());

            //Assert
            Assert.AreEqual(ExcpectedResult.Employee.EmployeeID, ActualResult.Employee.EmployeeID);
            Assert.AreEqual(ExcpectedResult.Employee.FirstName, ActualResult.Employee.FirstName);
            Assert.AreEqual(ExcpectedResult.Employee.NumberOfDependents, ActualResult.Employee.NumberOfDependents);
        }
コード例 #2
0
        public void Get_ReturnsAllEmployeeInformationObject()
        {
            //Arrange

            List <EmployeeInformation> listOdExpectedResult = new List <EmployeeInformation>();

            EmployeeInformation ExcpectedResult = Utility.ParseJSONArray <EmployeeInformation>(ReadJsonFromFile());

            listOdExpectedResult.Add(ExcpectedResult);

            _employeeData.Setup(x => x.Get()).Returns(listOdExpectedResult);

            var controller = new EmployeeDataController(_employeeData.Object);

            //Act
            var controllerResult = (OkObjectResult)controller.Get();

            List <EmployeeInformation> ActualResult = Utility.ParseJSONArray <List <EmployeeInformation> >(controllerResult.Value.ToString());


            //Assert
            Assert.AreEqual(listOdExpectedResult.Count, ActualResult.Count);
        }