public void TestClearReservesByJobId()
        {
            //Arrange
            FakeObjectSet<CS_Reserve> fakeReserveList = new FakeObjectSet<CS_Reserve>();
            fakeReserveList.AddObject
            (
                new CS_Reserve()
                    {
                        ID = 1,
                        Active = true,
                        CreateBy = "Load",
                        CreationDate = DateTime.Now,
                        DivisionID = 1,
                        Duration = 1,
                        EmployeeID = 1,
                        EquipmentTypeID = 1,
                        JobID = 1,
                        ModificationDate = DateTime.Now,
                        ModifiedBy = "Load",
                        StartDateTime = DateTime.Now,
                        Type = 1
                    }
            );
            fakeReserveList.AddObject
            (
                new CS_Reserve()
                {
                    ID = 2,
                    Active = true,
                    CreateBy = "Load",
                    CreationDate = DateTime.Now,
                    DivisionID = 1,
                    Duration = 1,
                    EquipmentTypeID = 1,
                    JobID = 1,
                    ModificationDate = DateTime.Now,
                    ModifiedBy = "Load",
                    StartDateTime = DateTime.Now,
                    Type = 1
                }
            );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Reserve>()).Returns(fakeReserveList);

            //Act
            ResourceAllocationModel model = new ResourceAllocationModel(mockUnitOfWork.Object);

            IList<CS_Reserve> reserveList = model.ClearReservesByJobId(1, "rbrandao");

            //Assert
            for (int i = 0; i < reserveList.Count; i++)
            {
                Assert.AreEqual(reserveList[i].Active, false);
            }
        }
        public void ShouldReturnCallLogListFilteredByCallTime()
        {
            //Arrange
            FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>();
            fakeCallLogList.AddObject(new CS_CallLog() { ID = 1, JobID = 1, Active = true, CallDate = new DateTime(2011, 05, 1) });
            fakeCallLogList.AddObject(new CS_CallLog() { ID = 2, JobID = 1, Active = true, CallDate = new DateTime(2011, 05, 10, 13, 45, 0) });
            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList);
            CallLogModel model = new CallLogModel(mockUnitOfWork.Object);

            //Act
            IList<CS_CallLog> callLogList = model.ListFilteredCallLogs(Core.Globals.JobRecord.FilterType.Time, "5/11/2011 13:45", 1);
            //Assert
            Assert.AreEqual(1, callLogList.Count);
            Assert.AreEqual(2, callLogList[0].ID);
        }
        public void CreateNewEmployee_SupervisorsCountryIsNotSame_ShouldThrowException()
        {
            //---------------------------------- ARRANGE -------------------------------------

            const string SUPERVISOR_COUNTRY = "USA";
            const string EMPLOYEE_COUNTRY = "UK";

            //creating sample data for other employee, that would contain the different COUNTRY of the new employee
            Employee supervisorEmployee = TestDataFactory.CreateNewObjectWithValidExistingEmployeeData();
            supervisorEmployee.Country = SUPERVISOR_COUNTRY;

            //populating sample data to ObjectSet container that would be considered as the data source in mock database for employee entities
            employeeObjectSet = new FakeObjectSet<Employee>();
            employeeObjectSet.AddObject(supervisorEmployee);

            //setting up the mock database with sample object
            mockDatabaseConext.Setup(db => db.Employees).Returns(employeeObjectSet);

            //creating sample data for new employee, that would contain the different COUNTRY of another employee loaded in mock database
            Employee newEmployee = TestDataFactory.CreateNewObjectWithValidNewEmployeeData();
            newEmployee.Country = EMPLOYEE_COUNTRY;
            newEmployee.Supervisor = supervisorEmployee;

            //---------------------------------- ACT -------------------------------------

            //perform the operation that is under test
            employeeBLL.CreateNewEmployee(newEmployee);
        }
        public void TestUpdateEquipment()
        {
            //Arrange
            CS_Equipment equipment = new CS_Equipment()
                                         {
                                             Active = true,
                                             ID = 1,
                                             Name = "Xyz",
                                             Status = "Up",
                                             HeavyEquipment = false
                                         };

            FakeObjectSet<CS_Equipment> fakeEquipment = new FakeObjectSet<CS_Equipment>();
            fakeEquipment.AddObject(equipment);

            Mock<IUnitOfWork> mockUnitWork = new Mock<IUnitOfWork>();
            mockUnitWork.Setup(w => w.CreateObjectSet<CS_Equipment>()).Returns(fakeEquipment);

            EquipmentModel model = new EquipmentModel(mockUnitWork.Object);

            //Act
            model.UpdateMaintenanceEquipment(equipment);
            CS_Equipment csEquipment = model.GetEquipment(1);

            //Assert

            Assert.AreEqual(Globals.EquipmentMaintenance.Status.Up.ToString(), csEquipment.Status, "Error on Status Field");
            Assert.AreEqual(false, csEquipment.HeavyEquipment, "Error on heavyequipment field.");
        }
        public void GetNotificationsTest()
        {
            var mockRepository = MockRepository.GenerateMock<IGameSchoolEntities>();
            var notificationService = new NotificationService();
            notificationService.SetDatasource(mockRepository);

            int userInfoId = 1;

            var list = CreateNotificationList(userInfoId, 20);

            var userData = new FakeObjectSet<UserInfo>();

            var userInfo = new UserInfo();
            userInfo.Fullname = "Davíð Einarsson";
            userInfo.Email = "*****@*****.**";
            userInfo.StatusId = 1;
            userInfo.Username = "******";
            userInfo.UserInfoId = userInfoId;
            userInfo.Password = "******";

            userData.AddObject(userInfo);

            mockRepository.Expect(x => x.UserInfoes).Return(userData);
            mockRepository.Expect(x => x.Notifications).Return(list);

            var actualList = notificationService.GetNotifications(userInfoId);

            Assert.AreEqual(list.Count(), actualList.Count());

            mockRepository.VerifyAllExpectations();
        }
Esempio n. 6
0
        public void GetEmployeeByEmployeeId_MethodCalledWithEmployeeId_ShouldGetCorrespondingEmployeeInfo()
        {
            //---------------------------------- ARRANGE -------------------------------------

            //setting up the in-memory database with required data for test
            FakeObjectSet <Employee> employeeObjectSet = new FakeObjectSet <Employee>();
            Employee employeeOldData = TestDataFactory.CreateNewObjectWithValidExistingEmployeeData();

            employeeObjectSet.AddObject(employeeOldData);
            mockDatabaseConext.Setup(db => db.Employees).Returns(employeeObjectSet);

            EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object);

            string EXPECTED_ADDRESS = employeeOldData.Address;

            //---------------------------------- ACT -------------------------------------

            Employee employeeNewData = employeeBLL.GetEmployeeByEmployeeId(1);

            //---------------------------------- ASSERT -------------------------------------

            string ACTUAL_ADDRESS = employeeNewData.Address;

            Assert.AreEqual(EXPECTED_ADDRESS, ACTUAL_ADDRESS, "Address should be found");
        }
        public void TestListAllFirstAlert()
        {
            //Arrange
            FakeObjectSet<CS_FirstAlert> fakeFirstAlert = new FakeObjectSet<CS_FirstAlert>();
            fakeFirstAlert.AddObject(new CS_FirstAlert() {
                Active = true,
                Number = "123",
                JobID = 1,
                CustomerID = 1,
                Details = "aaAaA",
                Date = new DateTime(2011, 7, 12, 5, 0, 0),
                HasPoliceReport = true,
                CreatedBy = "dcecilia",
                CreationDate = new DateTime(2011, 7, 12, 5, 0, 0),
                ModifiedBy = "dcecilia",
                ModificationDate = new DateTime(2011, 7, 12, 5, 0, 0)
            });
            Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>();

            mock.Setup(w => w.CreateObjectSet<CS_FirstAlert>()).Returns(fakeFirstAlert);

            FirstAlertModel model = new FirstAlertModel(mock.Object);

            //Act
            IList<CS_FirstAlert> results = model.ListAllFirstAlert();

            //Assert
            Assert.AreEqual(1, results.Count);
        }
Esempio n. 8
0
        public void CreateNewEmployee_SupervisorsCountryIsNotSame_ShouldThrowException()
        {
            //---------------------------------- ARRANGE -------------------------------------

            const string SUPERVISOR_COUNTRY = "USA";
            const string EMPLOYEE_COUNTRY   = "UK";

            //creating sample data for other employee, that would contain the different COUNTRY of the new employee
            Employee supervisorEmployee = TestDataFactory.CreateNewObjectWithValidExistingEmployeeData();

            supervisorEmployee.Country = SUPERVISOR_COUNTRY;

            //populating sample data to ObjectSet container that would be considered as the data source in mock database for employee entities
            employeeObjectSet = new FakeObjectSet <Employee>();
            employeeObjectSet.AddObject(supervisorEmployee);

            //setting up the mock database with sample object
            mockDatabaseConext.Setup(db => db.Employees).Returns(employeeObjectSet);

            //creating sample data for new employee, that would contain the different COUNTRY of another employee loaded in mock database
            Employee newEmployee = TestDataFactory.CreateNewObjectWithValidNewEmployeeData();

            newEmployee.Country    = EMPLOYEE_COUNTRY;
            newEmployee.Supervisor = supervisorEmployee;

            //---------------------------------- ACT -------------------------------------

            //perform the operation that is under test
            employeeBLL.CreateNewEmployee(newEmployee);
        }
Esempio n. 9
0
 public void AddObject()
 {
     Employee emp = new Employee();
     FakeObjectSet<Employee> set = new FakeObjectSet<Employee>();
     set.AddObject(emp);
     Assert.IsTrue(set.Contains(emp), "AddObject did not add supplied Employees to public Enumerator.");
 }
Esempio n. 10
0
        public void AddObject()
        {
            Employee emp = new Employee();
            FakeObjectSet <Employee> set = new FakeObjectSet <Employee>();

            set.AddObject(emp);
            Assert.IsTrue(set.Contains(emp), "AddObject did not add supplied Employees to public Enumerator.");
        }
Esempio n. 11
0
        public void NullArgumentChecks()
        {
            Utilities.CheckNullArgumentException(() => { new FakeObjectSet <Employee>(null); }, "testData", "ctor");

            FakeObjectSet <Employee> set = new FakeObjectSet <Employee>();

            Utilities.CheckNullArgumentException(() => { set.AddObject(null); }, "entity", "AddObject");
            Utilities.CheckNullArgumentException(() => { set.DeleteObject(null); }, "entity", "DeleteObject");
            Utilities.CheckNullArgumentException(() => { set.Attach(null); }, "entity", "Attach");
            Utilities.CheckNullArgumentException(() => { set.Detach(null); }, "entity", "Detach");
        }
        public void TestListCityByNameWithoutState()
        {
            //Arrange
            FakeObjectSet<CS_City> fakeCityList = new FakeObjectSet<CS_City>();
            fakeCityList.AddObject(new CS_City() { ID = 1, Active = true, Name = "City 1" });
            Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>();
            mock.Setup(e => e.CreateObjectSet<CS_City>()).Returns(fakeCityList);
            LocationModel model = new LocationModel(mock.Object);

            //Act
            IList<CS_City> city = model.ListCityByNameAndState(0, "City 1");

            //Assert
            Assert.AreEqual(1, city.Count);
            Assert.IsNotNull(city);
        }
Esempio n. 13
0
        public void GetEmployeeByEmployeeId_MethodCalledWithEmployeeId_ShouldGetCorrespondingEmployeeInfo()
        {
            //---------------------------------- ARRANGE -------------------------------------

            //setting up the in-memory database with required data for test
            FakeObjectSet<Employee> employeeObjectSet = new FakeObjectSet<Employee>();
            Employee employeeOldData = TestDataFactory.CreateNewObjectWithValidExistingEmployeeData();
            employeeObjectSet.AddObject(employeeOldData);
            mockDatabaseConext.Setup(db => db.Employees).Returns(employeeObjectSet);

            EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object);

            string EXPECTED_ADDRESS = employeeOldData.Address;

            //---------------------------------- ACT -------------------------------------

            Employee employeeNewData = employeeBLL.GetEmployeeByEmployeeId(1);

            //---------------------------------- ASSERT -------------------------------------

            string ACTUAL_ADDRESS = employeeNewData.Address;

            Assert.AreEqual(EXPECTED_ADDRESS, ACTUAL_ADDRESS, "Address should be found");
        }
Esempio n. 14
0
        public void TestIfTotalIsBeingCalculated()
        {
            // Arrange
            DateTime calculationDate = DateTime.Today;
            CS_DPI dpiEntry = new CS_DPI() { ID = 1, Active = true, ProcessStatus = (short)Globals.DPI.DpiStatus.Pending };
            CS_Job jobEntry = new CS_Job()
            {
                ID = 1,
                Active = true,
                EmergencyResponse = false,
                CS_JobInfo = new CS_JobInfo() { InitialCallDate = calculationDate, InitialCallTime = new TimeSpan(10, 0, 0), Active = true }
            };

            FakeObjectSet<CS_DPIResource> fakeDPIResource = new FakeObjectSet<CS_DPIResource>();
            fakeDPIResource.AddObject(new CS_DPIResource()
            {
                DPIID = dpiEntry.ID,
                CS_DPI = dpiEntry,
                EquipmentID = 1
            });
            fakeDPIResource.AddObject(new CS_DPIResource()
            {
                DPIID = dpiEntry.ID,
                CS_DPI = dpiEntry,
                EmployeeID = 1
            });

            FakeObjectSet<CS_CallLogResource> fakeCallLogResource = new FakeObjectSet<CS_CallLogResource>();
            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 13,
                        IsAutomaticProcess = false,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.Start,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Continuing field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date Continuing format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Continuing field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Continuing field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They're BACK!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "10:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
                },
                JobID = 1,
                CallLogID = 1,
                EquipmentID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
            });
            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 18,
                        IsAutomaticProcess = true,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.End,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Released field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Released Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Released field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They stopped working!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "15:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 15, 0, 0)
                },
                JobID = 1,
                CallLogID = 2,
                EquipmentID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 15, 0, 0)
            });

            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 13,
                        IsAutomaticProcess = false,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.Start,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Continuing field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date Continuing format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Continuing:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Continuing field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Continuing field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They're BACK!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "10:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
                },
                JobID = 1,
                CallLogID = 3,
                EmployeeID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 10, 0, 0)
            });
            fakeCallLogResource.AddObject(new CS_CallLogResource()
            {
                CS_CallLog = new CS_CallLog
                {
                    CS_CallType = new CS_CallType()
                    {
                        ID = 18,
                        IsAutomaticProcess = true,
                        DpiStatus = (int)Globals.DPI.CallTypeDpiStatus.End,
                        Active = true
                    },
                    Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Work Date Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{0}</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Work Date Released field is required</EmptyValueMessage><InvalidValueMessage>Invalid Work Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Work Time Released:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>{1}</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Work Time Released Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Work Time Released field is required.</EmptyValueMessage></DynamicControls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>They stopped working!</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                        calculationDate.ToString("yyyy-MM-dd"), "16:00"),
                    CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 16, 0, 0)
                },
                JobID = 1,
                CallLogID = 4,
                EmployeeID = 1,
                CreationDate = new DateTime(calculationDate.Year, calculationDate.Month, calculationDate.Day, 16, 0, 0)
            });

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPIResource>()).Returns(fakeDPIResource);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLogResource>()).Returns(fakeCallLogResource);

            // Act
            DPIModel model = new DPIModel(mockUnitOfWork.Object);
            IList<CS_DPIResource> returnList = model.ProcessDPIResources(dpiEntry, jobEntry, calculationDate);

            // Assert
            CS_DPIResource equipment = returnList.FirstOrDefault(e => e.EquipmentID == 1);
            CS_DPIResource employee = returnList.FirstOrDefault(e => e.EmployeeID == 1);
            Assert.AreEqual(equipment.Hours * equipment.Rate, equipment.Total);
            Assert.AreEqual(employee.Hours * employee.Rate, employee.Total);
        }
        public void TestIfEmployeeIsBeingUpdated()
        {
            // Arrange
            FakeObjectSet<CS_Employee> fakeEmployeeList = new FakeObjectSet<CS_Employee>();
            FakeObjectSet<CS_CallCriteria> fakeCallCriteriaList = new FakeObjectSet<CS_CallCriteria>();
            FakeObjectSet<CS_CallCriteriaValue> fakeCallCriteriaValueList = new FakeObjectSet<CS_CallCriteriaValue>();
            FakeObjectSet<CS_EmployeeCoverage> fakeEmployeeCoverageList = new FakeObjectSet<CS_EmployeeCoverage>();
            FakeObjectSet<CS_EmployeeOffCallHistory> fakeEmployeeOffCallList = new FakeObjectSet<CS_EmployeeOffCallHistory>();
            FakeObjectSet<CS_Settings> fakeSettingsList = new FakeObjectSet<CS_Settings>();
            FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>();
            FakeObjectSet<CS_CallLogResource> fakeCallLogResourceList = new FakeObjectSet<CS_CallLogResource>();
            FakeObjectSet<CS_Resource> fakeResourceList = new FakeObjectSet<CS_Resource>();
            FakeObjectSet<CS_PhoneNumber> fakePhoneList = new FakeObjectSet<CS_PhoneNumber>();

            fakeEmployeeList.AddObject(
                new CS_Employee()
                {
                    ID = 1,
                    Active = true,
                    HasAddressChanges = false,
                    HasPhoneChanges = false,
                }
            );
            fakeEmployeeList.AddObject(
                new CS_Employee()
                {
                    ID = 2,
                    Active = true,
                    HasAddressChanges = false,
                    HasPhoneChanges = false,
                }
            );
            fakeSettingsList.AddObject(
                new CS_Settings()
                {
                    ID = (int)Globals.Configuration.Settings.AddressChangeNotification,
                    Description = "*****@*****.**"
                }
            );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Employee>()).Returns(fakeEmployeeList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallCriteria>()).Returns(fakeCallCriteriaList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallCriteriaValue>()).Returns(fakeCallCriteriaValueList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_EmployeeCoverage>()).Returns(fakeEmployeeCoverageList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_EmployeeOffCallHistory>()).Returns(fakeEmployeeOffCallList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Settings>()).Returns(fakeSettingsList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallLogResource>()).Returns(fakeCallLogResourceList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Resource>()).Returns(fakeResourceList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_PhoneNumber>()).Returns(fakePhoneList);

            CS_Employee updateEmployee = new CS_Employee()
            {
                ID = 1,
                Address = "Testing Address"
            };

            CS_CallCriteria callCriteria = new CS_CallCriteria()
            {
                EmployeeID = 1,
                Active = true
            };

            IList<CS_CallCriteriaValue> callCriteriaValueList = new List<CS_CallCriteriaValue>();
            callCriteriaValueList.Add(new CS_CallCriteriaValue()
            {
                CallCriteriaTypeID = 1,
                Value = "testing",
                Active = true

            });

            CS_EmployeeCoverage coverage = new CS_EmployeeCoverage()
            {
                EmployeeID = 1,
                Active = true,
                CoverageStartDate = new DateTime(2011, 8, 29),
                Duration = 10,
                DivisionID = 1,
                CS_Employee = new CS_Employee() { ID = 1, Active = true, FullName = "Santos, Kleiton" },
                CS_Division = new CS_Division() { ID = 1, Active = true, Name = "001" }
            };

            CS_EmployeeOffCallHistory offCall = new CS_EmployeeOffCallHistory()
            {
                EmployeeID = 1,
                ProxyEmployeeID = 2,
                Active = true,
                OffCallStartDate = new DateTime(2011, 8, 29),
                OffCallEndDate = new DateTime(2011, 8, 31),
                OffCallReturnTime = new TimeSpan(10, 0, 0),
                CS_Employee = new CS_Employee() { ID = 1, Active = true, FullName = "Santos, Kleiton" },
                CS_Employee_Proxy = new CS_Employee() { ID = 2, Active = true, FullName = "Burton, Cynthia" }
            };

            // Act
            EmployeeModel model = new EmployeeModel(mockUnitOfWork.Object);
            model.SaveEmployee(updateEmployee, offCall, coverage, "system", true, true, new List<DataContext.VO.PhoneNumberVO>());

            // Assert
            Assert.AreEqual(1, fakeCallCriteriaList.Count());
            Assert.AreEqual(1, fakeCallCriteriaValueList.Count());
            Assert.AreEqual(1, fakeEmployeeOffCallList.Count());
            Assert.AreEqual(1, fakeEmployeeCoverageList.Count());
        }
Esempio n. 16
0
        public void TestListPresetNotification()
        {
            // Arrange
            FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>();
            fakeJobObject.AddObject(
                new CS_Job
                {
                    Active = true,
                    ID = 243,
                    Number = "123",
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 243,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus() { JobID = 243, JobStatusId = (int)Globals.JobRecord.JobStatus.Preset, Active = true }
                        }
                    },
                    CS_PresetInfo = new CS_PresetInfo()
                    {
                        JobId = 243,
                        Date = new DateTime(2011, 6, 15),
                        Time = new TimeSpan(16, 0, 0),
                        Active = true
                    }
                }
                );
            fakeJobObject.AddObject(
                new CS_Job
                {
                    Active = true,
                    ID = 244,
                    Number = "124",
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 244,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus() { JobID = 244, JobStatusId = (int)Globals.JobRecord.JobStatus.PresetPurchase, Active = true }
                        }
                    },
                    CS_PresetInfo = new CS_PresetInfo()
                    {
                        JobId = 244,
                        Date = new DateTime(2011, 6, 15),
                        Time = new TimeSpan(12, 0, 0),
                        Active = true
                    }
                }
                );
            fakeJobObject.AddObject(
                new CS_Job
                {
                    Active = true,
                    ID = 245,
                    Number = "125",
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 245,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus() { JobID = 245, JobStatusId = (int)Globals.JobRecord.JobStatus.Active, Active = true }
                        }
                    },
                    CS_PresetInfo = new CS_PresetInfo()
                }
                );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject);

            // Act
            JobModel jobModel = new JobModel(mockUnitOfWork.Object);
            IList<PresetNotificationVO> returnList = jobModel.ListPresetNotification(new DateTime(2011, 6, 16, 16, 32, 0));

            // Assert
            Assert.AreEqual(2, returnList.Count);
        }
Esempio n. 17
0
        public void TestFindJobSummaryByJobIds()
        {
            // Arrange
            FakeObjectSet<CS_SP_GetJobSummary_Result> fakeObjectSet = new FakeObjectSet<CS_SP_GetJobSummary_Result>();
            fakeObjectSet.AddObject(
                new CS_SP_GetJobSummary_Result()
                {
                    JobID = 1
                });
            fakeObjectSet.AddObject(
                new CS_SP_GetJobSummary_Result()
                {
                    JobID = 2
                });
            fakeObjectSet.AddObject(
                new CS_SP_GetJobSummary_Result()
                {
                    JobID = 3
                });
            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_SP_GetJobSummary_Result>()).Returns(fakeObjectSet);

            // Act
            JobModel jobModel = new JobModel(mockUnitOfWork.Object);
            IList<CS_View_JobSummary> returnList = jobModel.FindJobSummary(new List<int> { 1, 2 });

            // Assert
            Assert.AreEqual(2, returnList.Count);
        }
Esempio n. 18
0
        public void GenerateEmailSubjectsInvoicingTeamTest()
        {
            //Arrange
            FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>();
            fakeJobObject.AddObject(
                new CS_Job
                    {
                        Active = true,
                        ID = 243,
                        Number = "000123",
                        CS_CustomerInfo = new CS_CustomerInfo
                                              {
                                                  Active = true,
                                                  CS_Customer = new CS_Customer()
                                                                    {
                                                                        Active = true,
                                                                        Name = "Customer Test"
                                                                    }
                                              },
                        CS_JobInfo = new CS_JobInfo
                        {
                            CS_JobType = new CS_JobType() { ID = 1, Description = "A", Active = true },
                            CS_PriceType = new CS_PriceType() { ID = 1, Acronym = "P", Active = true },
                            CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus { JobStatusId = 1, JobID = 243, Active = true }
                        }
                        }
                    }
                );

            //Act
            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject);

            JobModel jobModel = new JobModel(mockUnitOfWork.Object);

            string subject = jobModel.GenerateEmailSubjectsInvoicingTeam(243);

            string expected = "PA000123, Customer Test";

            //Assert
            Assert.AreEqual(expected, subject);
        }
Esempio n. 19
0
        public void AnswerLevelExamQuestionTest()
        {
            /* Setup user data */
            int userInfoId = 1;

            var userData = new FakeObjectSet<UserInfo>();

            var user = UserServiceTest.GetUser(userInfoId, UserType.Student);

            userData.AddObject(user);

            /* Setup levelexamanswer data */
            var answerData = new FakeObjectSet<LevelExamAnswer>();
            
            var levelExamAnswer = new LevelExamAnswer();
            levelExamAnswer.LevelExamAnswerId = 1;
            levelExamAnswer.LevelExamQuestionId = 1;
            levelExamAnswer.UserInfoes.Add(user);

            var levelExamAnswerNumberTwo = new LevelExamAnswer();
            levelExamAnswerNumberTwo.LevelExamAnswerId = 2;
            levelExamAnswerNumberTwo.LevelExamQuestionId = 1;

            answerData.AddObject(levelExamAnswer);
            answerData.AddObject(levelExamAnswerNumberTwo);

            /* Setup levelexamquestion data*/
            var questionData = new FakeObjectSet<LevelExamQuestion>();

            var levelExamQuestion = new LevelExamQuestion();
            levelExamQuestion.LevelExamQuestionId = 1;
            levelExamQuestion.LevelExamAnswers.Add(levelExamAnswer);
            levelExamQuestion.LevelExamAnswers.Add(levelExamAnswerNumberTwo);

            questionData.AddObject(levelExamQuestion);

            /* Setup the mock expectations */
            _mockRepository.Expect(x => x.UserInfoes).Return(userData);
            _mockRepository.Expect(x => x.LevelExamAnswers).Return(answerData);
            _mockRepository.Expect(x => x.LevelExamQuestions).Return(questionData);
            _mockRepository.Expect(x => x.SaveChanges()).Return(1);

            /* Test the business logic */
            _levelService.AnswerLevelExamQuestion(1, userInfoId);
            _levelService.AnswerLevelExamQuestion(2,userInfoId);

            /* Verify all the mock calls */
            _mockRepository.VerifyAllExpectations();
        }
Esempio n. 20
0
        public void TestIfListDPICalculationJobsIsReturningCorrectJobs()
        {
            // Arrange
            DateTime calculationDate = new DateTime(2011, 8, 3);

            FakeObjectSet<CS_Job> fakeJobList = new FakeObjectSet<CS_Job>();
            fakeJobList.AddObject(
                new CS_Job()
                {
                    Active = true,
                    CS_JobInfo = new CS_JobInfo()
                    {
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus()
                            {
                                Active = true,
                                JobStatusId = (int)Globals.JobRecord.JobStatus.Active,
                                JobStartDate = calculationDate
                            }
                        }
                    },
                    CS_DPI = null
                }
            );
            fakeJobList.AddObject(
                new CS_Job()
                {
                    Active = true,
                    CS_JobInfo = new CS_JobInfo()
                    {
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus()
                            {
                                Active = true,
                                JobStatusId = (int)Globals.JobRecord.JobStatus.Active,
                                JobStartDate = calculationDate
                            }
                        }
                    },
                    CS_DPI = new EntityCollection<CS_DPI>()
                    {
                        new CS_DPI()
                        {
                            Active = true,
                            ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                            Date = calculationDate
                        }
                    }
                }
            );
            fakeJobList.AddObject(
                new CS_Job()
                {
                    Active = true,
                    CS_JobInfo = new CS_JobInfo()
                    {
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus()
                            {
                                Active = true,
                                JobStatusId = (int)Globals.JobRecord.JobStatus.Active,
                                JobStartDate = calculationDate.AddDays(-1)
                            }
                        }
                    },
                    CS_DPI = new EntityCollection<CS_DPI>()
                    {
                        new CS_DPI()
                        {
                            Active = true,
                            ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                            Date = calculationDate
                        }
                    }
                }
            );

            fakeJobList.AddObject(
                new CS_Job()
                {
                    Active = true,
                    CS_JobInfo = new CS_JobInfo()
                    {
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus()
                            {
                                Active = true,
                                JobStatusId = (int)Globals.JobRecord.JobStatus.Closed
                            }
                        }
                    },
                    CS_DPI = null
                }
            );

            fakeJobList.AddObject(
                new CS_Job()
                {
                    Active = true,
                    CS_JobInfo = new CS_JobInfo()
                    {
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus()
                            {
                                Active = true,
                                JobStatusId = (int)Globals.JobRecord.JobStatus.Active,
                                JobStartDate = calculationDate
                            }
                        }
                    },
                    CS_DPI = new EntityCollection<CS_DPI>()
                    {
                        new CS_DPI()
                        {
                            Active = true,
                            ProcessStatus = (int)Globals.DPI.DpiStatus.Approved,
                            Date = calculationDate
                        }
                    }
                }
            );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobList);

            DPIModel model = new DPIModel(mockUnitOfWork.Object);

            // Act
            IList<CS_Job> returnList = model.ListDPICalculationJobs(calculationDate);

            // Assert
            Assert.AreEqual(3, returnList.Count);
        }
Esempio n. 21
0
        public void TestSaveOperationNotAllowed()
        {
            //Arrange
            FakeObjectSet<CS_JobStatus> fakeStatusList = new FakeObjectSet<CS_JobStatus>();
            fakeStatusList.AddObject(new CS_JobStatus() { Active = true, ID = 2, Description = "Preset" });
            FakeObjectSet<CS_Job> fakeJobList = new FakeObjectSet<CS_Job>();
            fakeJobList.AddObject(
                new CS_Job()
                {
                    Active = true, ID = 1,
                    CS_CustomerInfo = new CS_CustomerInfo()
                    {
                        Active = true, CustomerId = 1
                    },
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 1, Active= true,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() {
                            new CS_Job_JobStatus(){
                                ID = 1, JobID = 1, JobStatusId = 2, Active= true
                            }
                        }
                    }
                }
            );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_JobStatus>()).Returns(fakeStatusList);
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobList);
            JobModel model = new JobModel(mockUnitOfWork.Object)
            {
                JobStatusID = 1,
                NewJob = new CS_Job()
                {
                    Active = true, ID = 1,
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 1, Active= true,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>() {
                            new CS_Job_JobStatus() {
                                ID = 1, JobID = 1, JobStatusId = 1, Active= true
                            }
                        }
                    }
                },
                NewCustomer = new CS_CustomerInfo()
                {
                    Active = true,
                    CustomerId = 1
                }
            };

            //Act
            IDictionary<string, object> output = model.UpdateJobData(false, true);

            //Assert
            Assert.IsTrue(output.ContainsKey("OperationNotAllowed"));
            Assert.IsTrue(bool.Parse(output["OperationNotAllowed"].ToString()));
            Assert.AreEqual("Cannot update Job Status to Active, because the previous status is Preset.", output["Message"].ToString());
        }
Esempio n. 22
0
        public void GetLevelProjectByUserIdTest_UserInfoCourseLevelLevelProject_CollectionOfLevelProjects()
        {
            var userInfoId = 7;

            var userData = new FakeObjectSet<UserInfo>();
            var courseData = new FakeObjectSet<Course>();
            var levelProjectData = new FakeObjectSet<LevelProject>();
            var levelData = new FakeObjectSet<Level>();

            LevelProject levelProject1 = new LevelProject { Stop = DateTime.Now.AddDays(7), Start = DateTime.Now, Name = "Verkefni", LevelProjectId = 1, ContentID = Guid.NewGuid(), Description = "Lýsing", GradePercentageValue = 5, LevelId = 1 };
            LevelProject levelProject2 = new LevelProject { Stop = DateTime.Now.AddDays(7), Start = DateTime.Now, Name = "Verkefni2", LevelProjectId = 2, ContentID = Guid.NewGuid(), Description = "Lýsing2", GradePercentageValue = 1, LevelId = 1 };
            UserInfo user1 = new UserInfo { Fullname = "Davíð Einarsson", Email = "*****@*****.**", StatusId = 1, Username = "******", UserInfoId = userInfoId, Password = "******" };
            Course course = new Course { CourseId = 1, Name = "Vefforritun I", CreateDateTime = DateTime.Now, Identifier = "VEFF", Start = DateTime.Now, Stop = DateTime.Now.AddDays(28), DepartmentId = 1, CreditAmount = 6, Description = "Lýsing á veff" };
            Level lvl = new Level { CourseId = 1, CreateDateTime = DateTime.Now, LevelId = 1, Name = "Level", Start = DateTime.Now, Stop = DateTime.Now.AddDays(7), OrderNum = 5 };

            course.Levels.Add(lvl);
            user1.Courses.Add(course);
            lvl.LevelProjects.Add(levelProject1);
            lvl.LevelProjects.Add(levelProject2);

            userData.AddObject(user1);
            courseData.AddObject(course);
            levelProjectData.AddObject(levelProject1);
            levelProjectData.AddObject(levelProject2);
            levelData.AddObject(lvl);

            _mockRepository.Expect(x => x.UserInfoes).Return(userData);
            _mockRepository.Expect(x => x.Courses).Return(courseData);
            _mockRepository.Expect(x => x.LevelProjects).Return(levelProjectData);
            _mockRepository.Expect(x => x.Levels).Return(levelData);

            var query = _levelService.GetLevelProjectsByUserId(userInfoId);

            var expectedUser = query.SelectMany(x => x.Level.Course.UserInfoes).FirstOrDefault();
            var expectedFirstLevelProject = query.Where(s => s.LevelProjectId == 1).FirstOrDefault();
            var expectedSecondLevelProject = query.Where(s => s.LevelProjectId == 2).FirstOrDefault();
            var expectedLevel = query.Where(x => x.Level.LevelId == 1).Select(x => x.Level).FirstOrDefault();
            var expectedCourse =
                query.Where(x => x.Level.Course.CourseId == 1).Select(x => x.Level.Course).FirstOrDefault();

            Assert.AreEqual(expectedCourse.Description, course.Description);
            Assert.AreEqual(expectedLevel.Name,lvl.Name);
            Assert.AreEqual(expectedSecondLevelProject.Name, levelProject2.Name);
            Assert.AreEqual(expectedFirstLevelProject.Name,levelProject1.Name);
            Assert.AreEqual(expectedUser.Fullname,user1.Fullname);
            Assert.AreEqual(expectedUser.Fullname, user1.Fullname);
            Assert.AreEqual(expectedUser.Fullname, user1.Fullname);
            Assert.AreEqual(expectedUser.Fullname, user1.Fullname);

            
        }
        public void TestUpdateResourceAllocation()
        {
            //Arrange
            IList<CS_Resource> resourceList = new List<CS_Resource>(){
                new CS_Resource() {
                    Active = true, CreatedBy = "Load", CreationDate = DateTime.Now, Description = "DescriptionTest",
                    Duration=1, EmployeeID = 1, EquipmentID =1, JobID = 1, ModificationDate = DateTime.Now,
                    ModifiedBy = "Load", StartDateTime = DateTime.Now, Type = 1,
                    CS_Equipment = new CS_Equipment(){
                        Name ="Sideboom",
                        CS_Division = new CS_Division() { ID = 1, Name = "no name", Active = true }
                    },
                    CS_Employee = new CS_Employee() { Name="Ruziska", FirstName="Danilo" }
                },
                new CS_Resource() {
                    Active = true, CreatedBy = "Load", CreationDate = DateTime.Now, Description = "DescriptionTest2",
                    Duration=1, EmployeeID = 1, EquipmentID =1, JobID = 1, ModificationDate = DateTime.Now,
                    ModifiedBy = "Load", StartDateTime = DateTime.Now, Type = 1,
                    CS_Equipment = new CS_Equipment(){
                        Name ="Sideboom",
                        CS_Division = new CS_Division() { ID = 1, Name = "no name", Active = true }
                    },
                    CS_Employee = new CS_Employee() { Name="Ruziska", FirstName="Danilo" }
                }
            };

            IList<CS_Reserve> reserveList = new List<CS_Reserve>(){
                new CS_Reserve() {
                    Active = true, CreateBy = "Load", CreationDate = DateTime.Now, DivisionID = 1, Duration = 1,
                    EmployeeID = 1, EquipmentTypeID = 1, JobID = 1, ModificationDate = DateTime.Now, ModifiedBy = "Load",
                    StartDateTime = DateTime.Now, Type = 1,
                    CS_EquipmentType = new CS_EquipmentType() { ID = 1, Name = "no name", Active = true },
                    CS_Division = new CS_Division() { ID = 1, Name = "no name", Active = true }
                },
                new CS_Reserve() {
                    Active = true, CreateBy = "Load", CreationDate = DateTime.Now, DivisionID = 1, Duration = 1,
                    EmployeeID = 1, EquipmentTypeID = null, JobID = 1, ModificationDate = DateTime.Now, ModifiedBy = "Load",
                    StartDateTime = DateTime.Now, Type = 1,
                    CS_Employee = new CS_Employee() {
                        ID = 1, Name = "no name", Active = true,
                        CS_Division = new CS_Division() { ID = 1, Name = "no name", Active = true }
                    }
                }
            };

            IList<int> lstDivisions = new List<int>();
            lstDivisions.Add(2);

            FakeObjectSet<CS_Resource> fakeResourceList = new FakeObjectSet<CS_Resource>();
            FakeObjectSet<CS_Reserve> fakeReserveList = new FakeObjectSet<CS_Reserve>();
            FakeObjectSet<CS_EquipmentPermit> fakePermitList = new FakeObjectSet<CS_EquipmentPermit>();
            FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>();
            FakeObjectSet<CS_CallLogResource> fakeCallLogResourceList = new FakeObjectSet<CS_CallLogResource>();
            FakeObjectSet<CS_CallType> fakeCallTypeList = new FakeObjectSet<CS_CallType>();
            fakeCallTypeList.AddObject(new CS_CallType() { ID = 1, Active = true });

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceList);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Reserve>()).Returns(fakeReserveList);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_EquipmentPermit>()).Returns(fakePermitList);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLogResource>()).Returns(fakeCallLogResourceList);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeList);

            //Act
            ResourceAllocationModel model = new ResourceAllocationModel(mockUnitOfWork.Object);
            model.SaveOrUpdateResourceAllocation(1, reserveList, resourceList, "druziska", lstDivisions, string.Empty, false, DateTime.Now, false, string.Empty, string.Empty);

            //Assert
            Assert.IsNotNull(model.ResourceSaved);
            Assert.IsNotNull(model.ReserveSaved);
        }
Esempio n. 24
0
        public void HasAccessToExamTest()
        {
            /* Setup user data */
            int userInfoId = 1;

            var user = UserServiceTest.GetUser(userInfoId, UserType.Student);

            /* Setup levelexam data */
            var levelExamData = new FakeObjectSet<LevelExam>();

            var levelExam = new LevelExam();
            levelExam.LevelExamId = 1;
            levelExam.Stop = DateTime.Now.AddDays(1);

            levelExamData.AddObject(levelExam);

            /* Setup level data */
            var level = new Level();
            level.LevelExams.Add(levelExam);

            /* Setup course data */
            var course = new Course();

            course.UserInfoes.Add(user);
            course.Levels.Add(level);

            /* Setup the mock expectations */
            _mockRepository.Expect(x => x.LevelExams).Return(levelExamData);

            /* Test the business logic */
            var actual = _levelService.HasAccessToExam(levelExam.LevelExamId, userInfoId);
            var shouldfailactual = _levelService.HasAccessToExam(levelExam.LevelExamId, userInfoId+1);

            /* Assert */
            Assert.AreEqual(true, actual);
            Assert.AreEqual(false, shouldfailactual);

            /* Verify all the mock calls */
            _mockRepository.VerifyAllExpectations();
        }
Esempio n. 25
0
        public void ReturnExamTest()
        {
            /* Setup user data */
            int userInfoId = 1;

            var user = UserServiceTest.GetUser(userInfoId, UserType.Student);

            /* Setup answer data*/
            var levelExamAnswer1 = new LevelExamAnswer();
            levelExamAnswer1.LevelExamAnswerId = 1;
            levelExamAnswer1.LevelExamQuestionId = 1;
            levelExamAnswer1.Correct = true;
            levelExamAnswer1.UserInfoes.Add(user);

            var levelExamAnswer2 = new LevelExamAnswer();
            levelExamAnswer2.LevelExamAnswerId = 2;
            levelExamAnswer2.LevelExamQuestionId = 2;
            levelExamAnswer2.Correct = true;
            levelExamAnswer2.UserInfoes.Add(user);

            var levelExamAnswer3 = new LevelExamAnswer();
            levelExamAnswer3.LevelExamAnswerId = 3;
            levelExamAnswer3.LevelExamQuestionId =3;
            levelExamAnswer3.Correct = true;
            levelExamAnswer3.UserInfoes.Add(user);

            var levelExamAnswer4 = new LevelExamAnswer();
            levelExamAnswer4.LevelExamAnswerId = 4;
            levelExamAnswer4.LevelExamQuestionId = 4;
            levelExamAnswer4.Correct = true;
            levelExamAnswer4.UserInfoes.Add(user);

            var levelExamAnswer5 = new LevelExamAnswer();
            levelExamAnswer5.LevelExamAnswerId = 5;
            levelExamAnswer5.LevelExamQuestionId = 5;
            levelExamAnswer5.Correct = true;
            levelExamAnswer5.UserInfoes.Add(user);

            /* Setup level exam question data */

            var levelExamQuestion1 = new LevelExamQuestion();
            levelExamQuestion1.LevelExamQuestionId = 1;
            levelExamQuestion1.LevelExamAnswers.Add(levelExamAnswer1);

            var levelExamQuestion2 = new LevelExamQuestion();
            levelExamQuestion2.LevelExamQuestionId = 2;
            levelExamQuestion2.LevelExamAnswers.Add(levelExamAnswer2);

            var levelExamQuestion3 = new LevelExamQuestion();
            levelExamQuestion3.LevelExamQuestionId = 3;
            levelExamQuestion3.LevelExamAnswers.Add(levelExamAnswer3);
            
            var levelExamQuestion4 = new LevelExamQuestion();
            levelExamQuestion4.LevelExamQuestionId = 4;
            levelExamQuestion4.LevelExamAnswers.Add(levelExamAnswer4);
            
            var levelExamQuestion5 = new LevelExamQuestion();
            levelExamQuestion5.LevelExamQuestionId = 5;
            levelExamQuestion5.LevelExamAnswers.Add(levelExamAnswer5);

            var levelExamQuestion6 = new LevelExamQuestion();
            levelExamQuestion6.LevelExamQuestionId = 6;

            var levelExamQuestion7 = new LevelExamQuestion();
            levelExamQuestion7.LevelExamQuestionId = 7;
            
            var levelExamQuestion8 = new LevelExamQuestion();
            levelExamQuestion8.LevelExamQuestionId = 8;
            
            var levelExamQuestion9 = new LevelExamQuestion();
            levelExamQuestion9.LevelExamQuestionId = 9;

            var levelExamQuestion10 = new LevelExamQuestion();
            levelExamQuestion10.LevelExamQuestionId = 10;

            /* Setup levelexam data */
            var levelExamData = new FakeObjectSet<LevelExam>();

            var levelExam = new LevelExam();
            levelExam.LevelExamId = 1;
            levelExam.Stop = DateTime.Now.AddDays(1);
            levelExam.LevelExamQuestions.Add(levelExamQuestion1);
            levelExam.LevelExamQuestions.Add(levelExamQuestion2);
            levelExam.LevelExamQuestions.Add(levelExamQuestion3);
            levelExam.LevelExamQuestions.Add(levelExamQuestion4);
            levelExam.LevelExamQuestions.Add(levelExamQuestion5);
            levelExam.LevelExamQuestions.Add(levelExamQuestion6);
            levelExam.LevelExamQuestions.Add(levelExamQuestion7);
            levelExam.LevelExamQuestions.Add(levelExamQuestion8);
            levelExam.LevelExamQuestions.Add(levelExamQuestion9);
            levelExam.LevelExamQuestions.Add(levelExamQuestion10);

            levelExamData.AddObject(levelExam);

            /* Setup level data */
            var level = new Level();
            level.LevelExams.Add(levelExam);

            /* Setup course data */
            var course = new Course();

            course.UserInfoes.Add(user);
            course.Levels.Add(level);

            /* Setup the mock expectations */
            _mockRepository.Expect(x => x.LevelExams).Return(levelExamData);
            _mockRepository.Expect(x => x.LevelExamResults).Return(new FakeObjectSet<LevelExamResult>());

            /* Test the business logic */
            var actual = _levelService.ReturnExam(1, 1);

            /* Assert */
            Assert.AreEqual(5, actual);
        }
Esempio n. 26
0
        public void GetUserQuestionAnswerTest()
        {
            /* Setup user data */
            int userInfoId = 1;

            var userData = new FakeObjectSet<UserInfo>();

            var user = UserServiceTest.GetUser(userInfoId, UserType.Student);

            userData.AddObject(user);

            /* Setup levelexamanswer data */
            var answerData = new FakeObjectSet<LevelExamAnswer>();

            var levelExamAnswer = new LevelExamAnswer();
            levelExamAnswer.LevelExamAnswerId = 1;
            levelExamAnswer.LevelExamQuestionId = 1;
            levelExamAnswer.UserInfoes.Add(user);

            var levelExamAnswerNumberTwo = new LevelExamAnswer();
            levelExamAnswerNumberTwo.LevelExamAnswerId = 2;
            levelExamAnswerNumberTwo.LevelExamQuestionId = 1;

            answerData.AddObject(levelExamAnswer);
            answerData.AddObject(levelExamAnswerNumberTwo);

            /* Setup levelexamquestion data*/
            var questionData = new FakeObjectSet<LevelExamQuestion>();

            var levelExamQuestion = new LevelExamQuestion();
            levelExamQuestion.LevelExamQuestionId = 1;
            levelExamQuestion.LevelExamAnswers.Add(levelExamAnswer);
            levelExamQuestion.LevelExamAnswers.Add(levelExamAnswerNumberTwo);

            questionData.AddObject(levelExamQuestion);

            /* Setup the mock expectations */
            _mockRepository.Expect(x => x.LevelExamQuestions).Return(questionData);

            /* Test the business logic */
            var actualOne = _levelService.GetUserQuestionAnswer(1, userInfoId);
            var actualTwo = _levelService.GetUserQuestionAnswer(1, userInfoId+1);

            /* Assert */
            Assert.AreEqual(levelExamAnswer.LevelExamAnswerId, actualOne);
            Assert.AreEqual(-1, actualTwo);

            /* Verify all the mock calls */
            _mockRepository.VerifyAllExpectations();
        }
Esempio n. 27
0
        public void TestIfListDPIResourcesIsReturningCorrectResources()
        {
            // Arrange
            int dpiID = 1;

            FakeObjectSet<CS_DPIResource> fakeDpiResourceList = new FakeObjectSet<CS_DPIResource>();
            fakeDpiResourceList.AddObject(
                new CS_DPIResource()
                {
                    DPIID = dpiID,
                    Active = true
                }
            );
            fakeDpiResourceList.AddObject(
                new CS_DPIResource()
                {
                    DPIID = dpiID,
                    Active = true
                }
            );
            fakeDpiResourceList.AddObject(
                new CS_DPIResource()
                {
                    DPIID = dpiID,
                    Active = true
                }
            );
            fakeDpiResourceList.AddObject(
                new CS_DPIResource()
                {
                    DPIID = dpiID,
                    Active = false
                }
            );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_DPIResource>()).Returns(fakeDpiResourceList);

            DPIModel model = new DPIModel(mockUnitOfWork.Object);

            // Act
            IList<CS_DPIResource> returnList = model.ListDPIResources(dpiID);

            // Assert
            Assert.AreEqual(3, returnList.Count);
        }
Esempio n. 28
0
        public void GenerateEmailBodyForInvoicingTeamTest()
        {
            DateTime dt = new DateTime(2011, 02, 14);

            TimeSpan timeSpan = new TimeSpan(10, 11, 59);

            CS_Country country = new CS_Country()
                                     {
                                         ID = 1,
                                         Active = true,
                                         Name = "USA"

                                     };

            CS_State state = new CS_State()
                                 {
                                     ID = 1,
                                     Active = true,
                                     Name = "Texas"
                                 };

            CS_City city = new CS_City()
                               {
                                   ID = 1,
                                   Active = true,
                                   Name = "Dalton"
                               };

            CS_LocationInfo locationInfo = new CS_LocationInfo()
                                            {
                                                Active = true,
                                                CountryID = 1,
                                                StateID = 1,
                                                CityID = 1,
                                                CS_Country = country,
                                                CS_State = state,
                                                CS_City = city
                                            };

            CS_Frequency frequency = new CS_Frequency()
                                         {
                                             Active = true,
                                             ID = 1,
                                             Description = "D"
                                         };

            CS_JobDescription csJobDescription = new CS_JobDescription()
            {
                Active = true,
                NumberEmpties = 1,
                NumberLoads = 2,
                NumberEngines = 1
            };

            CS_Division division = new CS_Division()
            {
                ID = 241,
                Active = true,
                Name = "005",
                Description = "White River, Ontario"
            };

            CS_JobDivision jobdivision = new CS_JobDivision()
            {
                Active = true,
                JobID = 243,
                DivisionID = 241,
                CS_Division = division
            };

            CS_Employee employee = new CS_Employee()
            {
                ID = 1,
                Active = true,
                Name = "Dcecilia",
                FirstName = "Test",
                DivisionID = 241
            };

            CS_Reserve reserve = new CS_Reserve()
            {
                Active = true,
                JobID = 243,
                Type = 2,
                CS_Employee = employee,
                DivisionID = 241
            };

            EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>();

            JobDivision.Add(jobdivision);

            CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork()
            {
                Active = true,
                ScopeOfWork = "xxcxcxc",
                JobId = 243
            };

            EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>();
            csReserves.Add(reserve);

            EntityCollection<CS_ScopeOfWork> scopeOfWorks = new EntityCollection<CS_ScopeOfWork>();
            scopeOfWorks.Add(csScopeOfWork);

            //Arrange
            FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>();
            fakeJobObject.AddObject
                (
                    new CS_Job()
                    {
                        ID = 243,
                        Active = true,
                        CreatedBy = "rbrandao",
                        CreationDate = DateTime.Now,
                        ModificationDate = DateTime.Now,
                        ModifiedBy = "Load",
                        //Internal_Tracking = "000000025INT",
                        Number = "000243",
                        CS_ScopeOfWork = scopeOfWorks,
                        CS_JobDivision = JobDivision,
                        CS_Reserve = csReserves,
                        CS_CustomerInfo = new CS_CustomerInfo()
                        {
                            Active = true,
                            CS_Customer = new CS_Customer()
                            {
                                Active = true,
                                Name = "American Test"
                            },
                            CS_Division = division,
                            CS_Contact1 = new CS_Contact()
                            {
                                ID = 1,
                                Active = true,
                                Name = "danilo",
                                LastName = "cecilia",
                            },
                            CS_Contact3 = new CS_Contact()
                                             {
                                                 ID = 1,
                                                 Active = true,
                                                 Name = "danilo",
                                                 LastName = "cecilia",
                                             },
                            //IsCustomer = true,
                            InitialCustomerContactId = 1,
                            BillToContactId = 1

                        },
                        CS_JobInfo = new CS_JobInfo()
                        {
                            Active = true,
                            InterimBill = true,
                            CS_Employee = employee,
                            EmployeeID = employee.ID,
                            CS_Frequency = frequency,
                            FrequencyID = 1,
                            CS_JobAction = new CS_JobAction()
                            {
                                Active = true,
                                Description = "Environmental Work, General - Undefined Scope of Work"
                            },
                            CS_JobType = new CS_JobType()
                            {
                                Active = true,
                                Description = "A"
                            },
                            InitialCallDate = dt,
                            InitialCallTime = timeSpan,
                            CS_PriceType = new CS_PriceType()
                                               {
                                                   Active = true,
                                                   Acronym = "P",
                                                   Description = "description test"
                                               },
                            CS_JobCategory = new CS_JobCategory()
                                                {
                                                    Active = true,
                                                    Description = "B"
                                                },
                            CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                            {
                                new CS_Job_JobStatus()
                                {
                                    Active = true,
                                    JobStatusId = (int)Globals.JobRecord.JobStatus.Active,
                                    JobStartDate = new DateTime(2011,02,14),
                                    JobCloseDate = new DateTime(2011,02,14)
                                }
                            }

                        },
                        CS_LocationInfo = locationInfo,
                        CS_JobDescription = csJobDescription
                    }
            );

            //Act
            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject);

            JobModel jobModel = new JobModel(mockUnitOfWork.Object);

            string body = jobModel.GenerateEmailBodyForInvoicingTeam(243);

            StringBuilder sb = new StringBuilder();

            sb.Append("<div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job#:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" PA000243");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Customer:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" American Test");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Initial Customer Contact:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" danilo");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Bill to:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" cecilia, danilo");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Initial Call date:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 02/14/2011");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Initial Call time:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 10:11:59");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Price Type:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" description test");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job Action:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Environmental Work, General - Undefined Scope of Work");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job Category:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" B");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job Type:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" A");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Division:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 005");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Interim Bill:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Yes");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Requested By:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Dcecilia, Test");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Frequency:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" D");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Country:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" USA");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("State:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Texas");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("City:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Dalton");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Number Engines:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 1");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Number Loads:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 2");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Number Empties:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 1");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Scope Of Work:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("xxcxcxc");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job start date:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 02/14/2011 00:00:00");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job end date:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 02/14/2011 00:00:00");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("</div>");

            //Assert
            Assert.AreEqual(sb.ToString(), body);
        }
 public void TestListFirstAlertPersonByFirstAlertID()
 {
     //Arrange
     FakeObjectSet<CS_FirstAlertPerson> fakePersonList = new FakeObjectSet<CS_FirstAlertPerson>();
     fakePersonList.AddObject(new CS_FirstAlertPerson() { Active = true, FirstAlertID = 1 });
     fakePersonList.AddObject(new CS_FirstAlertPerson() { Active = false, FirstAlertID = 1 });
     fakePersonList.AddObject(new CS_FirstAlertPerson() { Active = true, FirstAlertID = 2 });
     Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
     mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_FirstAlertPerson>()).Returns(fakePersonList);
     FirstAlertModel model = new FirstAlertModel(mockUnitOfWork.Object);
     //Act
     IList<CS_FirstAlertPerson> results = model.ListFirstAlertPersonByFirstAlertID(1);
     //Assert
     Assert.AreEqual(1, results.Count);
 }
Esempio n. 30
0
        public void GenerateEmailBodyForEstimationTeamTest()
        {
            DateTime dt = new DateTime(2011, 02, 14);

            CS_JobDescription csJobDescription = new CS_JobDescription()
                                                     {
                                                         Active = true,
                                                         NumberEmpties = 1,
                                                         NumberLoads = 2,
                                                         NumberEngines = 1
                                                     };

            CS_Division division = new CS_Division()
                                       {
                                           ID = 241,
                                           Active = true,
                                           Name = "005",
                                           Description = "White River, Ontario"
                                       };

            CS_JobDivision jobdivision = new CS_JobDivision()
                                          {
                                              Active = true,
                                              JobID = 243,
                                              DivisionID = 241,
                                              CS_Division = division
                                          };

            CS_Employee employee = new CS_Employee()
                                       {
                                           Active = true,
                                           Name = "Dcecilia",
                                           FirstName = "Test",
                                           DivisionID = 241
                                       };

            CS_Reserve reserve = new CS_Reserve()
                                     {
                                         Active = true,
                                         JobID = 243,
                                         Type = 2,
                                         CS_Employee = employee,
                                         DivisionID = 241
                                     };

            EntityCollection<CS_JobDivision> JobDivision = new EntityCollection<CS_JobDivision>();

            JobDivision.Add(jobdivision);

            CS_ScopeOfWork csScopeOfWork = new CS_ScopeOfWork()
            {
                Active = true,
                ScopeOfWork = "xxcxcxc",
                JobId = 243
            };

            EntityCollection<CS_Reserve> csReserves = new EntityCollection<CS_Reserve>();
            csReserves.Add(reserve);

            EntityCollection<CS_ScopeOfWork> scopeOfWorks = new EntityCollection<CS_ScopeOfWork>();
            scopeOfWorks.Add(csScopeOfWork);

            //Arrange
            FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>();
            fakeJobObject.AddObject
                (
                    new CS_Job()
                        {
                            ID = 243,
                            Active = true,
                            CreatedBy = "rbrandao",
                            CreationDate = DateTime.Now,
                            ModificationDate = DateTime.Now,
                            ModifiedBy = "Load",
                            Internal_Tracking = "000000025INT",
                            CS_ScopeOfWork = scopeOfWorks,
                            CS_JobDivision = JobDivision,
                            CS_Reserve = csReserves,
                            CS_CustomerInfo = new CS_CustomerInfo()
                                                  {
                                                      Active = true,
                                                      CS_Customer = new CS_Customer()
                                                                        {
                                                                            Active = true,
                                                                            Name = "Test Customer"
                                                                        },
                                                      CS_Division = division
                                                  },
                            CS_JobInfo = new CS_JobInfo()
                                             {
                                                 Active = true,
                                                 CS_JobAction = new CS_JobAction()
                                                                    {
                                                                        Active = true,
                                                                        Description = "Environmental Work, General - Undefined Scope of Work"
                                                                    },
                                                 CS_JobType = new CS_JobType()
                                                                    {
                                                                        Active = true,
                                                                        Description = "A"
                                                                    },
                                                 CS_PriceType = new CS_PriceType()
                                                 {
                                                     Active = true,
                                                     Acronym = "P"
                                                 },
                                                CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                                                                    {
                                                                        new CS_Job_JobStatus()
                                                                        {
                                                                            JobStatusId = (int)Globals.JobRecord.JobStatus.Bid,
                                                                            JobStartDate = new DateTime(2011,02,14),
                                                                            Active = true
                                                                        }
                                                                    }

                                             },
                            CS_JobDescription = csJobDescription
                        }
            );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject);

            JobModel jobModel = new JobModel(mockUnitOfWork.Object);

            string body = jobModel.GenerateEmailBodyForEstimationTeam(243);

            StringBuilder sb = new StringBuilder();

            sb.Append("<div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Proposal#:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" ##");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job#:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" PA000000025INT");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Customer:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Test Customer");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Division:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 005");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("JobType:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" A");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("JobAction:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Environmental Work, General - Undefined Scope of Work");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Scope Of Work:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("xxcxcxc");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Job start date:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append("02/14/2011 00:00:00");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Employee:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" Dcecilia, Test");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Number Engines:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 1");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Number Loads:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 2");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("<div style='width: 100%; display: inline-block;'>");
            sb.Append("<div style='text-align: right;width:30%; height:100% ;display: inline-block;float:left'><b>");
            sb.Append("Number Empties:");
            sb.Append("</b></div>");
            sb.Append("<div style='text-align: left;width:68%; height:100% ;display: inline-block;float:right'>");
            sb.Append(" 1");
            sb.Append("</div>");
            sb.Append("</div>");
            sb.Append("</div>");

            Assert.AreEqual(sb.ToString(), body);
        }
        public void TestListFilteredFirstAlert()
        {
            //Arrange
            FakeObjectSet<CS_FirstAlert> fakeFirstAlert = new FakeObjectSet<CS_FirstAlert>();

            CS_FirstAlertType csFirstAlertType = new CS_FirstAlertType()
                                                     {
                                                         Active = true,
                                                         Description = "injury",
                                                         CreatedBy = "dcecilia",
                                                         CreationDate = new DateTime(10, 10, 10, 5, 0, 1),
                                                         ModifiedBy = "dcecilia",
                                                         ModificationDate = new DateTime(10, 10, 10, 5, 0, 1),

                                                     };

            CS_FirstAlertFirstAlertType csFirstAlertFirstAlertType = new CS_FirstAlertFirstAlertType()
            {
                Active = true,
                FirstAlertID = 1,
                FirstAlertTypeID = 1,
                CreatedBy = "dcecilia",
                CreationDate =
                    new DateTime(10, 10, 10, 5, 0, 1),
                ModifiedBy = "dcecilia",
                ModificationDate =
                    new DateTime(10, 10, 10, 5, 0, 1),
                CS_FirstAlertType = csFirstAlertType
            };

            EntityCollection<CS_FirstAlertFirstAlertType> entityCollectionFirstAlertFirstAlertType = new EntityCollection<CS_FirstAlertFirstAlertType>();
            entityCollectionFirstAlertFirstAlertType.Add(csFirstAlertFirstAlertType);

            fakeFirstAlert.AddObject(new CS_FirstAlert()
            {
                Active = true,
                Number = "123",
                JobID = 1,
                CustomerID = 1,
                Details = "aaAaA",
                Date = new DateTime(2011, 7, 12, 5, 0, 0),
                HasPoliceReport = true,
                CreatedBy = "dcecilia",
                CreationDate = new DateTime(2011, 7, 12, 5, 0, 0),
                ModifiedBy = "dcecilia",
                ModificationDate = new DateTime(2011, 7, 12, 5, 0, 0),
                CS_FirstAlertFirstAlertType = entityCollectionFirstAlertFirstAlertType,
            });

            Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>();

            mock.Setup(w => w.CreateObjectSet<CS_FirstAlert>()).Returns(fakeFirstAlert);

            FirstAlertModel model = new FirstAlertModel(mock.Object);

            //Act
            IList<CS_FirstAlert> results = model.ListFilteredFirstAlert(Globals.FirstAlert.FirstAlertFilters.IncidentType, "injury" );

            //Assert
            Assert.AreEqual(1, results.Count);
        }
Esempio n. 32
0
        public void UpdateLevelMaterialTest()
        {
            var materialData = new FakeObjectSet<LevelMaterial>();

            LevelMaterial expected = new LevelMaterial();
            expected.Title = "Fyrstu skilaboðin";
            expected.Description = "Ekki sérlega merkileg skilaboð";
            expected.ContentId = System.Guid.NewGuid();


            materialData.AddObject(expected);

            _mockRepository.Expect(x => x.LevelMaterials).Return(materialData);

            //_mockRepository.Expect(x => x.AttachTo("UserInfo", userInfo));
            _mockRepository.Expect(x => x.SaveChanges()).Return(1);

            _levelService.UpdateLevelMaterial(expected);


            _mockRepository.VerifyAllExpectations(); // Make sure everything was called correctly.
        }
Esempio n. 33
0
        public void CreateLevelTest()
        {
            var levelData = new FakeObjectSet<Level>();

            Level expected = new Level();
            expected.LevelId = 1;
            expected.Name = "Borð 1";
            expected.CourseId = 1;
            expected.Start = DateTime.Now;
            expected.Stop = DateTime.Now.AddDays(7);



            levelData.AddObject(expected);

            _mockRepository.Expect(x => x.Levels).Return(levelData);

            //_mockRepository.Expect(x => x.AttachTo("Levels",expected));
            _mockRepository.Expect(x => x.SaveChanges()).Return(1);

            _levelService.CreateLevel(expected);

            var actual = _levelService.GetLevel(1);

            Assert.AreEqual(actual.Name, expected.Name);


            _mockRepository.VerifyAllExpectations(); // Make sure everything was called correctly.
        }
Esempio n. 34
0
        public void NullArgumentChecks()
        {
            Utilities.CheckNullArgumentException(() => { new FakeObjectSet<Employee>(null); }, "testData", "ctor");

            FakeObjectSet<Employee> set = new FakeObjectSet<Employee>();
            Utilities.CheckNullArgumentException(() => { set.AddObject(null); }, "entity", "AddObject");
            Utilities.CheckNullArgumentException(() => { set.DeleteObject(null); }, "entity", "DeleteObject");
            Utilities.CheckNullArgumentException(() => { set.Attach(null); }, "entity", "Attach");
            Utilities.CheckNullArgumentException(() => { set.Detach(null); }, "entity", "Detach");
        }