示例#1
0
        public void FindEmployees_FromDateAndEndDateAreEqual_FilterCorrectlyAppliedToOneDay()
        {
            //var service = new EmployeeReservationService();
            //service.FindEmployees()

            Employee employee = new Employee();
            employee.Reservations.Add(new Reservation() { CustomerId = 1, End = DateTime.Now, Start = DateTime.Now });

            var serializer = new XmlSerializer(typeof(Employee));
            using (TextWriter writer = new StreamWriter(@"C:\Temp\employee.xml"))
            {
                serializer.Serialize(writer, employee);
            }
        }
示例#2
0
 private static EmployeeInfo CreateEmployeeInfo(Employee employee)
 {
     return new EmployeeInfo
     {
         Id = employee.Id,
         FirstName = employee.FirstName,
         LastName = employee.LastName,
         Street = employee.Street,
         ZipCode = employee.ZipCode,
         City = employee.City,
         Phone = employee.Phone,
         EMail = employee.EMail,
         CareerLevel = employee.CareerLevel,
         Skills = (employee.Skills ?? new List<Skill>()).ToArray()
     };
 }
示例#3
0
        public void IsAvailableTest()
        {
            var reservations = new[]
                                   {
                                       new Reservation { Start = new DateTime(2014,1,1), End = new DateTime(2014,1,10)},
                                       new Reservation { Start = new DateTime(2013,12,21), End = new DateTime(2014,1,4)},
                                       new Reservation { Start = new DateTime(2014,2,1), End = new DateTime(2014,5,30)},
                                   };
            var e = new Employee();
            e.Reservations.AddRange(reservations);

            Assert.IsTrue(e.IsAvailable(new DateTime(2012, 1, 1)));
            Assert.IsTrue(e.IsAvailable(new DateTime(2013, 12, 20)));
            Assert.IsFalse(e.IsAvailable(new DateTime(2013, 12, 21)));
            Assert.IsFalse(e.IsAvailable(new DateTime(2014, 1, 1)));
            Assert.IsFalse(e.IsAvailable(new DateTime(2014, 1, 10)));
            Assert.IsTrue(e.IsAvailable(new DateTime(2014, 1, 11)));
            Assert.IsTrue(e.IsAvailable(new DateTime(2014, 1, 31)));
            Assert.IsFalse(e.IsAvailable(new DateTime(2014, 3, 5)));
        }
示例#4
0
        public void HasAnyAvailableTimeTest()
        {
            var reservations = new[]
                                   {
                                       new Reservation { Start = new DateTime(2014,1,1), End = new DateTime(2014,1,10)},
                                       new Reservation { Start = new DateTime(2013,12,21), End = new DateTime(2014,1,4)},
                                       new Reservation { Start = new DateTime(2014,2,1), End = new DateTime(2014,5,30)},
                                   };
            var e = new Employee();
            e.Reservations.AddRange(reservations);

            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2010, 1, 1), new DateTime(2011, 1, 1)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2013, 1, 1), new DateTime(2014, 1, 1)));
            Assert.IsFalse(e.HasAnyAvailableTime(new DateTime(2013, 12, 21), new DateTime(2013, 12, 21)));
            Assert.IsFalse(e.HasAnyAvailableTime(new DateTime(2013, 12, 21), new DateTime(2014, 1, 1)));
            Assert.IsFalse(e.HasAnyAvailableTime(new DateTime(2013, 12, 25), new DateTime(2014, 1, 9)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2013, 12, 25), new DateTime(2014, 1, 12)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2013, 12, 25), new DateTime(2015, 1, 12)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2014, 1, 8), new DateTime(2014, 1, 12)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2014, 1, 31), new DateTime(2014, 2, 5)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2014, 1, 31), new DateTime(2014, 7, 5)));
            Assert.IsFalse(e.HasAnyAvailableTime(new DateTime(2014, 3, 15), new DateTime(2014, 4, 15)));
            Assert.IsTrue(e.HasAnyAvailableTime(new DateTime(2014, 3, 15), new DateTime(2015, 7, 5)));
        }
        private static IEnumerable<Employee> CreateEmployees()
        {
            var e1 = new Employee
            {
                Id = 1,
                FirstName = "Roger",
                LastName = "Federerr",
                CareerLevel = CareerLevel.SoftwareEngineer,
            };

            e1.Skills.AddRange(new[] { Skill.CSharp, Skill.SqlServer });
            e1.Reservations.AddRange(new[]
            {
                new Reservation {CustomerId = 1, Start = new DateTime(2013, 1, 1), End = new DateTime(2013, 2, 1)},
                new Reservation {CustomerId = 2, Start = new DateTime(2013, 3, 1), End = new DateTime(2013, 4, 1)},
            });

            var e2 = new Employee
            {
                Id = 2,
                FirstName = "Pipilotti",
                LastName = "Rist",
                CareerLevel = CareerLevel.JuniorSoftwareEngineer,
            };

            e2.Skills.AddRange(new[] { Skill.CSharp, Skill.WCF });
            e2.Reservations.AddRange(new[]
            {
                new Reservation { CustomerId = 1, Start = new DateTime(2013, 1, 1), End = new DateTime(2014, 1, 1) }
            });

            var employees = new[] { e1, e2 };
            return employees;
        }
示例#6
0
        public void SetEmployee(Employee employee)
        {
            if (employee.Id <= 0)
            {
                throw new ArgumentException("Employee ID is invalid.");
            }

            RemoveEmployee(this.Employees, employee.Id);
            this.Employees.Add(employee);

            DataAccess.WriteEmployeesToFile(employeeListFileName, this.Employees);
        }
示例#7
0
        private Employee CreateEmployeeEntity(EmployeeInfo employeeInfo)
        {
            var employee = new Employee
            {
                Id = employeeInfo.Id,
                FirstName = employeeInfo.FirstName,
                LastName = employeeInfo.LastName,
                Street = employeeInfo.Street,
                ZipCode = employeeInfo.ZipCode,
                City = employeeInfo.City,
                Phone = employeeInfo.Phone,
                EMail = employeeInfo.EMail,
                CareerLevel = employeeInfo.CareerLevel
            };

            if (employeeInfo.Skills != null)
            {
                employee.Skills.AddRange(employeeInfo.Skills);
            }

            return employee;
        }
示例#8
0
        public void SkillTest()
        {
            var e = new Employee();
            e.Skills.AddRange(new[] { Skill.SqlServer, Skill.CloudComputing, });

            Assert.IsTrue(e.HasSkill(Skill.SqlServer));
            Assert.IsTrue(e.HasSkill(Skill.CloudComputing));
            Assert.IsFalse(e.HasSkill(Skill.WCF));
        }
示例#9
0
        public void NoSkillTest()
        {
            var e = new Employee();

            Assert.IsFalse(e.HasSkill(Skill.WCF));
        }