コード例 #1
0
        /// <summary>
        /// ثبت کارمند جدید
        /// </summary>
        /// <param name="employee">کارمند</param>
        /// <returns>کارمند ثبت شده</returns>
        public Employee CreateEmployee(Employee employee)
        {
            PersistenceObjectRepository <Employee> .Create(employee);

            m_profilePictureRepository.Save(employee.ID.ToString(), employee.ProfilePicture);
            return(employee);
        }
コード例 #2
0
        /// <summary>
        /// بروز رسانی اطلاعات کارمند
        /// </summary>
        /// <param name="employee">کارمند</param>
        /// <returns>کارمند با اطلاعات بروز شده</returns>
        public Employee UpdateEmployee(Employee employee)
        {
            Employee updatedEmployee = PersistenceObjectRepository <Employee> .Update(employee);

            m_profilePictureRepository.Save(updatedEmployee.ID.ToString(), updatedEmployee.ProfilePicture);
            return(updatedEmployee);
        }
 public void RetrieveAll_WhenCalled_ReturnsEmployeesList()
 {
     for (int i = 0; i < 2; i++)
     {
         PersistenceObjectRepository <Employee> .Create(newEmployeeSample());
     }
     Expect(PersistenceObjectRepository <Employee> .RetrieveAll().Count, Is.EqualTo(2));
 }
        public void Retrieve_ProvidedWithID_ReturnsContactInformationInstance()
        {
            var contactInformation = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

            var employee = PersistenceObjectRepository <Employee> .Create(newEmployeeSample(contactInformation));

            Expect(() => PersistenceObjectRepository <ContactInformation> .Retrieve(contactInformation.ID), Is.Not.EqualTo(Guid.Empty));
        }
コード例 #5
0
        /// <summary>
        /// ثبت گزارش خطای جدید
        /// </summary>
        /// <param name="log">گزارش خطا</param>
        /// <returns>گزارش خطای ثبت شده</returns>
        public Log CreateLog(Log log)
        {
            Log l_log = PersistenceObjectRepository <Log> .Create(log);

            m_logPictureRepository.Save(l_log.ID.ToString(), l_log.Picture);

            return(log);
        }
        public void Update_WhenCalled_ContactInformationIsUpdated()
        {
            ContactInformation returnValue = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

            returnValue.Label = "Work";
            ContactInformation updatedValue = PersistenceObjectRepository <ContactInformation> .Update(returnValue);

            Expect(updatedValue.Label, Is.EqualTo(returnValue.Label));
        }
        public void Update_WhenCalled_EmployeeIsUpdated()
        {
            Employee returnValue = PersistenceObjectRepository <Employee> .Create(newEmployeeSample());

            returnValue.FirstName = "Mohammad";
            Employee updatedValue = PersistenceObjectRepository <Employee> .Update(returnValue);

            Expect(updatedValue.FirstName, Is.EqualTo(returnValue.FirstName));
        }
        public void Truncate_WhenCalledOnEmployee_DeletesAllEmployees()
        {
            PersistenceObjectRepository <Employee> .Create(newEmployeeSample());


            PersistenceObjectRepository <Employee> .Truncate();

            Expect(() => PersistenceObjectRepository <Employee> .RetrieveAll().Count, Is.EqualTo(0));
        }
コード例 #9
0
        /// <summary>
        /// ثبت لیستی از خطا ها
        /// </summary>
        /// <param name="logs">لیستی از خطا ها</param>
        public void CreateLogs(IList <Log> logs)
        {
            PersistenceObjectRepository <Log> .Create(logs);

            foreach (Log log in logs)
            {
                m_logPictureRepository.Save(log.ID.ToString(), log.Picture);
            }
        }
        public void Delete_WhenCalled_ContactInformationIsDeleted()
        {
            var returnValue = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

            PersistenceObjectRepository <ContactInformation> .Delete(returnValue);

            Guid removedId = returnValue.ID;

            Expect(() => PersistenceObjectRepository <ContactInformation> .Retrieve(removedId), Is.Null);
        }
        public void Delete_WhenCalled_EmployeeIsDeleted()
        {
            var returnValue = PersistenceObjectRepository <Employee> .Create(newEmployeeSample());

            PersistenceObjectRepository <Employee> .Delete(returnValue);

            Guid removedId = returnValue.ID;

            Expect(() => PersistenceObjectRepository <Employee> .Retrieve(removedId), Is.Null);
        }
        public void RetrieveAttendanceTimes_WhenCalled_ReturnsListOfAllAttendanceTimes()
        {
            ContactInformation contactInformation = null;
            Employee           employee           = null;

            Expect(() => { contactInformation = AutomatedAttendanceSystem.CreateContactInformation(CommonTestCaseSourceProvider.newContactInformationSample()); }, Throws.Nothing);
            Expect(() => { employee = AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample(contactInformation)); }, Throws.Nothing);
            Expect(() => { PersistenceObjectRepository <AttendanceTime> .Create(CommonTestCaseSourceProvider.newAttendanceTimeSample(employee)); }, Throws.Nothing);
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes().Count, Is.GreaterThan(0));
        }
コード例 #13
0
        /// <summary>
        /// بازیابی کارمند با شناسه داخلی
        /// </summary>
        /// <param name="id">شناسه داخلی</param>
        /// <returns>کارمند</returns>
        public Employee RetrieveEmployee(Guid id)
        {
            var employee = PersistenceObjectRepository <Employee> .Retrieve(id);

            if (employee != null)
            {
                employee.ProfilePicture = m_profilePictureRepository.Read(employee.ID.ToString());
            }
            return(employee);
        }
        public void Truncate_WhenCalledOnContactInformation_DeletesAllContactInformations()
        {
            var contactInformation = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

            var employee = PersistenceObjectRepository <Employee> .Create(newEmployeeSample(contactInformation));

            PersistenceObjectRepository <ContactInformation> .Truncate();

            Expect(() => PersistenceObjectRepository <ContactInformation> .RetrieveAll().Count, Is.EqualTo(0));
        }
コード例 #15
0
        /// <summary>
        /// بازیابی خطا ها
        /// </summary>
        /// <returns>لیستی از تمام خطا ها</returns>
        public List <Log> RetrieveLogs()
        {
            var logList = PersistenceObjectRepository <Log> .RetrieveAll();

            foreach (Log log in logList)
            {
                log.Picture = m_logPictureRepository.Read(log.ID.ToString());
            }
            return(logList);
        }
コード例 #16
0
        /// <summary>
        ///بازیابی تمام کارمندان
        /// </summary>
        /// <returns>لیستی از تمام کارمندان</returns>
        public List <Employee> RetrieveEmployees()
        {
            var employeeList = PersistenceObjectRepository <Employee> .RetrieveAll();

            foreach (Employee e in employeeList)
            {
                e.ProfilePicture = m_profilePictureRepository.Read(e.ID.ToString());
            }

            return(employeeList);
        }
        public void RetrieveAll_WhenCalled_ReturnsContactInformationList()
        {
            for (int i = 0; i < 2; i++)
            {
                var contactInformation = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

                var employee = PersistenceObjectRepository <Employee> .Create(newEmployeeSample(contactInformation));
            }

            Expect(PersistenceObjectRepository <ContactInformation> .RetrieveAll().Count, Is.EqualTo(2));
        }
        public void Employee_WhenContactInformationsIsAccessed_ContactInformationsAreRetrieved()
        {
            var contactInformation = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

            Guid id = PersistenceObjectRepository <Employee> .Create(newEmployeeSample(contactInformation)).ID;

            Employee employee;

            Expect(employee = PersistenceObjectRepository <Employee> .Retrieve(id), Is.Not.Null);

            Expect(() => employee.ContactInformations.Count, Is.EqualTo(1));
        }
コード例 #19
0
        /// <summary>
        /// کل سیتسم را ریست می کند، استفاده در موارد تست
        /// </summary>
        private void reset()
        {
            m_attendedEmployees = new List <Employee>();
            PersistenceObjectRepository <ContactInformation> .Truncate();

            PersistenceObjectRepository <AttendanceTime> .Truncate();

            PersistenceObjectRepository <Employee> .Truncate();

            PersistenceObjectRepository <Log> .Truncate();

            m_instace = new AutomatedAttendanceSystem();
        }
コード例 #20
0
        /// <summary>
        ///ثبت ساعت ورودی
        /// </summary>
        /// <param name="employee">کارمند</param>
        /// <returns>زمان حضور</returns>
        public AttendanceTime RegisterEmployeeEntryTime(Employee employee)
        {
            ///[Registering entry time]
            AttendanceTime attendanceTime = new AttendanceTime()
            {
                Employee  = employee,
                EntryTime = DateTime.Now,
            };

            return(PersistenceObjectRepository <AttendanceTime> .Create(attendanceTime));

            ///[Registering entry time]
        }
        public void RetrieveAttendaceTimes_WhenCalledAfterRetrieveEmployees_Passes()
        {
            //Data
            var employee       = CommonTestCaseSourceProvider.newEmployeeSample();
            var attendanceTime = CommonTestCaseSourceProvider.newAttendanceTimeSample(employee);

            //Tests
            Expect(() => employee       = AutomatedAttendanceSystem.CreateEmployee(employee), Throws.Nothing);
            Expect(() => attendanceTime = PersistenceObjectRepository <AttendanceTime> .Create(attendanceTime), Throws.Nothing);

            Expect(() => AutomatedAttendanceSystem.RetrieveEmployees(), Throws.Nothing);
            Expect(() => AutomatedAttendanceSystem.RetrieveEmployees(), Is.Not.Empty);
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes(), Throws.Nothing);
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes(), Is.Not.Empty);
        }
        public void RetrieveAttendaceTimes_WhenCalled_ReturnsAllAttendanceTimes()
        {
            //Data
            var employee       = CommonTestCaseSourceProvider.newEmployeeSample();
            var attendanceTime = CommonTestCaseSourceProvider.newAttendanceTimeSample(employee);

            //Tests
            Expect(() => employee       = AutomatedAttendanceSystem.CreateEmployee(employee), Throws.Nothing);
            Expect(() => attendanceTime = PersistenceObjectRepository <AttendanceTime> .Create(attendanceTime), Throws.Nothing);

            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes().Count, Is.EqualTo(1));
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes(), Is.TypeOf <List <AttendanceTime> >());
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes()[0], Is.TypeOf <AttendanceTime>());
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes()[0], Is.EqualTo(attendanceTime));
        }
コード例 #23
0
        /// <summary>
        /// ثبت ساعت خروج
        /// </summary>
        /// <param name="employee">کارمند</param>
        /// <returns>زمان خروج</returns>
        public AttendanceTime RegisterEmployeeExitTime(Employee employee)
        {
            if (employee == null)
            {
                return(null);
            }
            ///[Registering exit time]
            AttendanceTime attendanceTime = new AttendanceTime();

            attendanceTime = RetrieveAttendanceTimes().Where((at) => at.Employee == employee).Last();
            attendanceTime.Employee.ProfilePicture = m_profilePictureRepository.Read(attendanceTime.Employee.ID.ToString());
            attendanceTime.ExitTime = DateTime.Now;

            return(PersistenceObjectRepository <AttendanceTime> .Update(attendanceTime));

            ///[Registering exit time]
        }
        public void RetrieveAttendaceTimes_WhenCalled_EmployeeMemberIsAccessible()
        {
            //Data
            var employee       = CommonTestCaseSourceProvider.newEmployeeSample();
            var attendanceTime = CommonTestCaseSourceProvider.newAttendanceTimeSample(employee);

            //Tests
            Expect(() => employee       = AutomatedAttendanceSystem.CreateEmployee(employee), Throws.Nothing);
            Expect(() => attendanceTime = PersistenceObjectRepository <AttendanceTime> .Create(attendanceTime), Throws.Nothing);

            //Is not empty
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes(), Throws.Nothing);
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes(), Is.Not.Empty);

            //Employee is accesisble
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes()[0].Employee, Is.Not.Null);
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes()[0].Employee, Is.EqualTo(employee));
        }
コード例 #25
0
 /// <summary>
 /// ثبت کامند جدید یا بروز رسانی کارمند موجود
 /// </summary>
 /// <param name="employee">کارمند</param>
 /// <returns>کارمند جدید، یا کارمند با اطلاعات بروز شده</returns>
 public Employee CreateOrUpdateEmployee(Employee employee)
 {
     return(PersistenceObjectRepository <Employee> .CreateOrUpdate(employee));
 }
        public void Retrieve_ProvidedWithID_ReturnsEmployeeInstance()
        {
            var returnValue = PersistenceObjectRepository <Employee> .Create(newEmployeeSample());

            Expect(() => PersistenceObjectRepository <Employee> .Retrieve(returnValue.ID), Is.Not.Null);
        }
コード例 #27
0
 /// <summary>
 /// برگرداندن لیست تمامی ساعات حضور
 /// </summary>
 /// <returns>لیستی از تمام ساعات حضور</returns>
 public List <AttendanceTime> RetrieveAttendanceTimes()
 {
     return(PersistenceObjectRepository <AttendanceTime> .RetrieveAll());
 }
コード例 #28
0
 /// <summary>
 /// ثبت اطلاعات تماس جدید
 /// </summary>
 /// <param name="contactInformation">اطلاعات تماس</param>
 /// <returns>ا</returns>
 public ContactInformation CreateContactInformation(ContactInformation contactInformation)
 {
     return(PersistenceObjectRepository <ContactInformation> .Create(contactInformation));
 }
コード例 #29
0
        private void INSERT_SAMPLE_DATA(bool insert = true, bool truncate_old_data = false)
        {
            if (!insert)
            {
                return;
            }

            if (truncate_old_data)
            {
                PersistenceObjectRepository <AttendanceTime> .Truncate();
            }

            if (false)
            {
                foreach (Employee employee in RetrieveEmployees())
                {
                    employee.WorkSchedule.DefineRange(DayOfWeek.Saturday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Sunday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Monday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Tuesday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Wednesday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Thursday, 9, 17, WorkSchedule.State.Work);
                    PersistenceObjectRepository <Employee> .Update(employee);
                }
            }

            List <AttendanceTime> attendanceTimeSampleData = new List <AttendanceTime>();
            int       year      = 2014;
            int       month     = DateTime.Now.Month;
            int       day       = DateTime.Now.Day - 5;
            DayOfWeek dayofWeek = (new DateTime(year, month, day)).DayOfWeek;

            attendanceTimeSampleData.Add(new AttendanceTime()
            {
                Employee = RetrieveEmployees()[4], //Binda Binder
                //AttendanceHours = new WorkSchedule(),
                EntryTime = new DateTime(year, month, day, 09, 0, 0, 0),
                ExitTime  = new DateTime(year, month, day, 21, 0, 0, 0)
            });


            attendanceTimeSampleData.Add(new AttendanceTime()
            {
                Employee = RetrieveEmployees()[2], //محمد طالبی
                //   AttendanceHours = new WorkSchedule(),
                EntryTime = new DateTime(year, month, day, 09, 0, 0, 0),
                ExitTime  = new DateTime(year, month, day, 17, 0, 0, 0)
            });


            attendanceTimeSampleData.Add(new AttendanceTime()
            {
                Employee  = RetrieveEmployees()[0], //Abbas Allahyari
                EntryTime = new DateTime(year, month, day, 18, 0, 0),
                ExitTime  = new DateTime(year, month, day, 23, 0, 0),
                //    AttendanceHours = new WorkSchedule(),
            });


            foreach (AttendanceTime at in attendanceTimeSampleData)
            {
                PersistenceObjectRepository <AttendanceTime> .Create(at);
            }

            List <ContactInformation> contactInformationSampleData = new List <ContactInformation>()
            {
                new ContactInformation()
                {
                    Label           = "Home",
                    PhoneNumber     = "02199115532",
                    CellphoneNumber = "09126512321",
                    Email           = "*****@*****.**",
                    Address         = "No 3, Valiasr, Tehran",
                    PostalCode      = "1434567891",
                    Employee        = RetrieveEmployees()[0]
                },
                new ContactInformation()
                {
                    Label           = "Grandpa",
                    PhoneNumber     = "02188115532",
                    CellphoneNumber = "09326512321",
                    Email           = "*****@*****.**",
                    Address         = "No 5, Ponak, Tehran",
                    PostalCode      = "1434567893",
                    Employee        = RetrieveEmployees()[0]
                }
            };

#if false
            RetrieveEmployees()[0].ContactInformations.Add(contactInformationSampleData[0]);
            RetrieveEmployees()[0].ContactInformations.Add(contactInformationSampleData[1]);
            PersistenceObjectRepository <Employee> .Update(RetrieveEmployees()[0]);
#endif
        }
コード例 #30
0
        /// <summary>
        /// حذف کارمند
        /// </summary>
        /// <param name="employee">کازمند</param>
        public void DeleteEmployee(Employee employee)
        {
            PersistenceObjectRepository <Employee> .Delete(employee);

            m_profilePictureRepository.Delete(employee.ID.ToString());
        }