public EmployeeResponseVm[] GetEmployees()
        {
            var employees       = _context.Employees.ToArray();
            var employeeMapping = new EmployeeMapping();

            return(employeeMapping.DataModelToRetrievalViewModel(employees));
        }
Exemplo n.º 2
0
        public void EmployeeDataModelIsNullThenArgumentExceptionIsThrown()
        {
            //Arrange
            Employee employeeDataModel = null;
            var      employeeMapping   = new EmployeeMapping();

            //Assert
            Assert.Throws <ArgumentException>(() => employeeMapping.DataModelToRetrievalViewModel(employeeDataModel));
        }
Exemplo n.º 3
0
        public void MapsEmptyEmployeeDataModelArrayToEmployeeRetrievalViewModelArray()
        {
            //Arrange
            Employee[] employeeDataModelArray = { };
            var        employeeMapping        = new EmployeeMapping();

            //Act
            var employeeResponseVmArray = employeeMapping.DataModelToRetrievalViewModel(employeeDataModelArray);

            //Assert
            Assert.IsInstanceOf(typeof(EmployeeResponseVm[]), employeeResponseVmArray);
        }
Exemplo n.º 4
0
        public void MapsEmployeeDataModelToEmployeeRetrievalViewModelWhichIsNotNull()
        {
            //Arrange
            var employeeDataModel = new Employee
            {
                EmployeeId = 1, Email = "*****@*****.**", EmployeeNumber = 1, FullName = "John Doe",
                DOB        = new DateTime(), StartDate = new DateTime(), Salary = 500000, ClubId = 1, LicenseId = 1
            };
            var employeeMapping = new EmployeeMapping();

            //Act
            var employeeResponseVm = employeeMapping.DataModelToRetrievalViewModel(employeeDataModel);

            //Assert
            Assert.IsNotNull(employeeResponseVm);
        }
Exemplo n.º 5
0
        public void MapsEmployeeDataModelToEmployeeRetrievalViewModelHasAllRequiredDataMatching()
        {
            //Arrange
            var employeeDataModel = new Employee
            {
                EmployeeId = 1, Email = "*****@*****.**", EmployeeNumber = 1, FullName = "John Doe",
                DOB        = new DateTime(), StartDate = new DateTime(), Salary = 500000, ClubId = 1, LicenseId = 1
            };
            var employeeMapping = new EmployeeMapping();

            //Act
            var employeeResponseVm = employeeMapping.DataModelToRetrievalViewModel(employeeDataModel);

            //Assert
            Assert.AreEqual(employeeDataModel.EmployeeId, employeeResponseVm.EmployeeId);
            Assert.AreEqual(employeeDataModel.Email, employeeResponseVm.Email);
            Assert.AreEqual(employeeDataModel.EmployeeNumber, employeeResponseVm.EmployeeNumber);
            Assert.AreEqual(employeeDataModel.FullName, employeeResponseVm.FullName);
            Assert.AreEqual(employeeDataModel.DOB, employeeResponseVm.DOB);
            Assert.AreEqual(employeeDataModel.StartDate, employeeResponseVm.StartDate);
            Assert.AreEqual(employeeDataModel.Salary, employeeResponseVm.Salary);
        }
Exemplo n.º 6
0
        public void MapsTwoEmployeeDataModelsInArrayToEmployeeRetrievalViewModelArrayWhichHasTwoElements()
        {
            //Arrange
            Employee[] employeeDataModelArray =
            {
                new Employee
                {
                    EmployeeId = 1, Email = "*****@*****.**", EmployeeNumber = 1, FullName = "John Doe",
                    DOB        = new DateTime(), StartDate = new DateTime(), Salary = 500000, ClubId = 1, LicenseId = 1
                },
                new Employee
                {
                    EmployeeId = 1, Email = "*****@*****.**", EmployeeNumber = 1, FullName = "John Doe",
                    DOB        = new DateTime(), StartDate = new DateTime(), Salary = 500000, ClubId = 1, LicenseId = 1
                }
            };
            var employeeMapping = new EmployeeMapping();

            //Act
            var employeeResponseVm = employeeMapping.DataModelToRetrievalViewModel(employeeDataModelArray);

            //Assert
            Assert.AreEqual(2, employeeResponseVm.Length);
        }