public void SetUp()
 {
     this.AutomatedAttendanceSystem = AutomatedAttendanceSystem.CreateInstance();
     AutomatedAttendanceSystem.Initialize();
     AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());
     AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());
 }
        public void RetrieveEmployee_ProvidedWithID_ReturnsEmployeeInstance()
        {
            var  returnValue         = AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());
            Guid retrievedEmployeeId = returnValue.ID;

            Expect(() => AutomatedAttendanceSystem.RetrieveEmployee(retrievedEmployeeId), Is.Not.Null);
        }
        private Employee util_createSampleEmployeeAndContactInformation()
        {
            ContactInformation contactInformation = null;
            Employee           employee           = null;

            Expect(() => { contactInformation = AutomatedAttendanceSystem.CreateContactInformation(CommonTestCaseSourceProvider.newContactInformationSample()); }, Throws.Nothing);
            Expect(() => { employee = AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample(contactInformation)); }, Throws.Nothing);
            return(employee);
        }
        public void DeleteEmployee_WhenCalled_EmployeeIsDeletedFromDatabase()
        {
            var returnValue = AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());

            Expect(() => AutomatedAttendanceSystem.DeleteEmployee(returnValue), Throws.Nothing);

            Guid removedId = returnValue.ID;

            Expect(() => AutomatedAttendanceSystem.RetrieveEmployee(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));
        }
        public void SetUp()
        {
            //this.AutomatedAttendanceSystem = new AutomatedAttendanceSystemProxy();

            AutomatedAttendanceSystem = MockRepository.GenerateDynamicMockWithRemoting <IAutomatedAttendanceSystem>();

            AutomatedAttendanceSystem.Initialize();
            AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());
            // AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());
        }
        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));
        }
        public void RegisterEmployeeEntryTime_WhenCalled_RegistersEntryTimeInDatabase()
        {
            ContactInformation contactInformation = null;
            Employee           employee           = null;

            Expect(() => { contactInformation = AutomatedAttendanceSystem.CreateContactInformation(CommonTestCaseSourceProvider.newContactInformationSample()); }, Throws.Nothing);
            Expect(() => { employee = AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample(contactInformation)); }, Throws.Nothing);

            DateTime       entryTime      = DateTime.Now;
            AttendanceTime attendanceTime = null;

            Expect(() => { attendanceTime = AutomatedAttendanceSystem.RegisterEmployeeEntryTime(employee); }, Throws.Nothing);
            Expect(() => attendanceTime.ID, Is.Not.EqualTo(Guid.Empty));
            Expect(() => AutomatedAttendanceSystem.RetrieveAttendanceTimes().Count, Is.EqualTo(1));
        }
        public void ResetAllCommand_WhenExecuteMethodIsCalled_EmployeeIsReset()
        {
            //Mock
            Employee employeeInstance = getEmployeeInstance(employee_Ahmad_Rahimi_0004000001);

            employeeInstance.WorkSchedule = WorkSchedule.MinValue;
            employeeInstance.ContactInformations.Add(CommonTestCaseSourceProvider.newContactInformationSample());

            //Test
            //   Expect(() => employee_Ahmad_Rahimi_0004000001.ResetAllCommand.Execute(null), Throws.Nothing);
            Expect(() => employee_Ahmad_Rahimi_0004000001.FirstName, Is.Null);
            Expect(() => employeeInstance.WorkSchedule, Is.EqualTo(WorkSchedule.MinValue));
            Expect(() => employeeInstance.ContactInformations[0].Label, Is.EqualTo(null));
            Expect(() => employeeInstance.ContactInformations.Count, Is.EqualTo(0));
        }
        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));
        }
        public void CreateEmployee_ProvidedWithEmployee_SavesInDatabase()
        {
            var returnValue = AutomatedAttendanceSystem.CreateEmployee(CommonTestCaseSourceProvider.newEmployeeSample());

            Expect(() => returnValue.ID, Is.Not.EqualTo(Guid.Empty));
        }
        public void CreateContactInformation_ProvidedWithContactInformation_SavesInDatabase()
        {
            var contactInformation = AutomatedAttendanceSystem.CreateContactInformation(CommonTestCaseSourceProvider.newContactInformationSample());

            Expect(() => contactInformation.ID, Is.Not.EqualTo(Guid.Empty));
        }