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 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(); }
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 Attach() { Employee emp = new Employee(); FakeObjectSet<Employee> set = new FakeObjectSet<Employee>(); set.Attach(emp); Assert.IsTrue(set.Contains(emp), "Attach did not add supplied Employees to public Enumerator."); }
public void InitializationWithTestData() { Employee emp = new Employee(); FakeObjectSet <Employee> set = new FakeObjectSet <Employee>(new Employee[] { emp }); Assert.IsTrue(set.Contains(emp), "Constructor did not add supplied Employees to public Enumerator."); }
public void Detach() { Employee emp = new Employee(); FakeObjectSet<Employee> set = new FakeObjectSet<Employee>(new Employee[] { emp }); set.Detach(emp); Assert.IsFalse(set.Contains(emp), "Detach did not remove supplied Employees to public Enumerator."); }
public void GetUserTest() { //Assign var userData = new FakeObjectSet<UserInfo>(); var expected = new UserInfo(); expected.Fullname = "Davíð Einarsson"; expected.Email = "*****@*****.**"; expected.StatusId = 1; expected.Username = "******"; expected.UserInfoId = 1; userData.AddObject(expected); _mockRepository.Expect(x => x.UserInfoes).Return(userData); int userId = 1; UserInfo actual = _userService.GetUser(userId); Assert.IsNotNull( actual); Assert.AreEqual(expected.Username, actual.Username); _mockRepository.VerifyAllExpectations(); // Make sure everything was correctly called. }
public void ClientRepositoryDataModel_GetByName_Success_Test() { MVoxAuditingEntities.AllInstances.MessageClientsGet = (c) => { FakeObjectSet <MessageClient> objectSet = new FakeObjectSet <MessageClient>(); objectSet.Add(new MessageClient() { MessageClientID = 1, MessageClientIdentifier = "Test" }); return(objectSet); }; MVoxAuditingEntities.AllInstances.BatchesGet = (c) => { FakeObjectSet <DataModel.Batch> objectSet = new FakeObjectSet <DataModel.Batch>(); objectSet.Add(new DataModel.Batch() { BatchID = 1, BatchNumber = "TestBatch", MessageClientID = 1, FinishDate = null, StartDate = DateTime.Now }); return(objectSet); }; var result = repository.GetByName("Test"); Assert.IsNotNull(result); Assert.AreEqual(1, result.ID); }
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); }
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 Attach() { Employee emp = new Employee(); FakeObjectSet <Employee> set = new FakeObjectSet <Employee>(); set.Attach(emp); Assert.IsTrue(set.Contains(emp), "Attach did not add supplied Employees to public Enumerator."); }
public void Detach() { Employee emp = new Employee(); FakeObjectSet <Employee> set = new FakeObjectSet <Employee>(new Employee[] { emp }); set.Detach(emp); Assert.IsFalse(set.Contains(emp), "Detach did not remove supplied Employees to public Enumerator."); }
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 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 CreateNewEmployee_MethodCalledWithEmployeeId_ShouldRunSuccessfully() { //setting up the in-memory database with required data for test FakeObjectSet<Employee> employeeObjectSet = new FakeObjectSet<Employee>(); mockDatabaseConext.Setup(db => db.Employees).Returns(employeeObjectSet); mockDatabaseConext.Setup(db => db.SaveChanges()).Returns(1); EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object); Employee employeeNewData = TestDataFactory.CreateNewObjectWithValidNewEmployeeData(); employeeBLL.CreateNewEmployee(employeeNewData); }
public void CreateNewEmployee_MethodCalledWithEmployeeId_ShouldRunSuccessfully() { //setting up the in-memory database with required data for test FakeObjectSet <Employee> employeeObjectSet = new FakeObjectSet <Employee>(); mockDatabaseConext.Setup(db => db.Employees).Returns(employeeObjectSet); mockDatabaseConext.Setup(db => db.SaveChanges()).Returns(1); EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object); Employee employeeNewData = TestDataFactory.CreateNewObjectWithValidNewEmployeeData(); employeeBLL.CreateNewEmployee(employeeNewData); }
public void BatchRepositoryDataModel_Add_ExistingBatchOpen_Test() { MVoxAuditingEntities.AllInstances.BatchesGet = (c) => { FakeObjectSet<Batch> objectSet = new FakeObjectSet<Batch>(); objectSet.Add(new Batch() { BatchID = 1, BatchNumber = "Test", MessageClientID = 1, StartDate = DateTime.Now }); return objectSet; }; bool result = repository.Add(new Model.Batch(0, "Test1") { ClientID = 1 }); }
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); }
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 MessageRepositoryDataModel_GetByID_Success_Test() { MVoxAuditingEntities.AllInstances.MessagesGet = (c) => { FakeObjectSet <DataModel.Message> objectSet = new FakeObjectSet <DataModel.Message>(); objectSet.Add(new DataModel.Message() { MessageID = 1, MessageNumber = "Test" }); return(objectSet); }; var result = repository.GetByID(1); Assert.IsNotNull(result); Assert.AreEqual(1, result.ID); }
public void BatchRepositoryDataModel_GetByName_Success_Test() { MVoxAuditingEntities.AllInstances.BatchesGet = (c) => { FakeObjectSet <Batch> objectSet = new FakeObjectSet <Batch>(); objectSet.Add(new Batch() { BatchID = 1, BatchNumber = "Test" }); return(objectSet); }; var result = repository.GetByName("Test"); Assert.IsNotNull(result); Assert.AreEqual(1, result.ID); }
public void ClientRepositoryDataModel_GetByID_Success_Test() { MVoxAuditingEntities.AllInstances.MessageClientsGet = (c) => { FakeObjectSet <MessageClient> objectSet = new FakeObjectSet <MessageClient>(); objectSet.Add(new MessageClient() { MessageClientID = 1, MessageClientIdentifier = "Test" }); return(objectSet); }; var result = repository.GetByID(1); Assert.IsNotNull(result); Assert.AreEqual(1, result.ID); }
public void GetEmployeeByEmployeeId_NonZeroEmployeeIdPassed_ShouldCall_DatabaseContext_Employees_PropertyGet() { /*The reason to use FakeObjectSet is, CreateNewEmployee method includes query level operation for business logic, we need to use FakeObjectSet. If no query was used we could use IObjectSet mock.*/ FakeObjectSet <Employee> employees = new FakeObjectSet <Employee>(); //setting up expectation for the DatabaseContext.Employees property to be called mockDatabaseConext.Setup(_db => _db.Employees).Verifiable(); //an EmployeeDatabaseContext.Employees ObjectSet is required for invoking IObjectSet.AddObject method mockDatabaseConext.Setup(_db => _db.Employees).Returns(employees); EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object); //calling the method for expected method verification employeeBLL.GetEmployeeByEmployeeId(1); mockDatabaseConext.Verify(); }
public void BatchRepositoryDataModel_Update_DoesNotExist_Test() { MVoxAuditingEntities.AllInstances.BatchesGet = (c) => { FakeObjectSet <Batch> objectSet = new FakeObjectSet <Batch>(); objectSet.Add(new Batch() { BatchID = 1, BatchNumber = "Test", MessageClientID = 1, StartDate = DateTime.Now }); return(objectSet); }; bool result = repository.Update(new Model.Batch(2, "Test1") { ClientID = 1, FinishDate = DateTime.Now }); }
public void MessageRepositoryDataModel_GetMessageApplicationID_Success_Test() { Guid aGuid = Guid.NewGuid(); MVoxAuditingEntities.AllInstances.MessageApplicationsGet = (c) => { FakeObjectSet <DataModel.MessageApplication> objectSet = new FakeObjectSet <DataModel.MessageApplication>(); objectSet.Add(new DataModel.MessageApplication() { MessageApplicationID = 1, MessageApplicationGuid = aGuid, MessageApplicationName = "Test" }); return(objectSet); }; var result = repository.GetMessageApplicationID(aGuid); Assert.AreEqual(1, result); }
public void MessageRepositoryDataModel_GetByGuid_Success_Test() { Guid aGuid = Guid.NewGuid(); MVoxAuditingEntities.AllInstances.MessagesGet = (c) => { FakeObjectSet <DataModel.Message> objectSet = new FakeObjectSet <DataModel.Message>(); objectSet.Add(new DataModel.Message() { MessageID = 1, MessageNumber = aGuid.ToString() }); return(objectSet); }; var result = repository.GetByGuid(aGuid); Assert.IsNotNull(result); Assert.AreEqual(1, result.ID); }
public void CreateNewEmployee_NewEmployeeObjectPassed_ShouldCall_DatabaseContext_SaveChanges_Method() { /*The reason to use FakeObjectSet is, CreateNewEmployee method includes query level operation for business logic, we need to use FakeObjectSet. If no query was used we could use IObjectSet mock.*/ FakeObjectSet<Employee> employees = new FakeObjectSet<Employee>(); //setting up expectation for the DatabaseContext.SaveChanges method to be called mockDatabaseConext.Setup(_db => _db.SaveChanges()).Verifiable(); //an EmployeeDatabaseContext.Employees ObjectSet is required for invoking IObjectSet.AddObject method mockDatabaseConext.Setup(_db => _db.Employees).Returns(employees); mockDatabaseConext.Setup(_db => _db.SaveChanges()).Returns(1); EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object); //calling the method for expected method verification employeeBLL.CreateNewEmployee(TestDataFactory.CreateNewObjectWithValidNewEmployeeData()); mockDatabaseConext.Verify(); }
public void CreateNewEmployee_NewEmployeeObjectPassed_ShouldCall_DatabaseContext_SaveChanges_Method() { /*The reason to use FakeObjectSet is, CreateNewEmployee method includes query level operation for business logic, we need to use FakeObjectSet. If no query was used we could use IObjectSet mock.*/ FakeObjectSet <Employee> employees = new FakeObjectSet <Employee>(); //setting up expectation for the DatabaseContext.SaveChanges method to be called mockDatabaseConext.Setup(_db => _db.SaveChanges()).Verifiable(); //an EmployeeDatabaseContext.Employees ObjectSet is required for invoking IObjectSet.AddObject method mockDatabaseConext.Setup(_db => _db.Employees).Returns(employees); mockDatabaseConext.Setup(_db => _db.SaveChanges()).Returns(1); EmployeeBLL employeeBLL = new EmployeeBLL(mockDatabaseConext.Object); //calling the method for expected method verification employeeBLL.CreateNewEmployee(TestDataFactory.CreateNewObjectWithValidNewEmployeeData()); mockDatabaseConext.Verify(); }
public void When_CarbrandRepository_GetByName_is_called_should_only_return_brands_that_match_parameter(string name) { //arrange var fakeObjectContext = A.Fake<IObjectContext>(); var fakeObjectSet = new FakeObjectSet<Carbrand>(new List<Carbrand> { new Carbrand() {CarbrandID = 1, Name = "Mercedes"}, new Carbrand() {CarbrandID = 2, Name = "Fiat"} }); A.CallTo(() => fakeObjectContext.CreateObjectSet<Carbrand>()).Returns(fakeObjectSet); var carbrandRepository = new CarbrandRepository(fakeObjectContext); //act var result = carbrandRepository.GetByName(name); //assert Assert.That(result, Has.Property("Name").EqualTo(name)); }
public void AddPointsToLevel() { var userData = new FakeObjectSet<Level>(); var levelId = 1; var pointsId = 1; var userInfoId = 1; var courseId = 1; var points = 50; Point point = new Point { CourseId = courseId, LevelId = levelId, PointsId = pointsId, Points = points, UserInfoId = userInfoId, Description = "Description" }; Assert.IsNotNull(point); //TODO: Finish implementation }
public void BatchRepositoryDataModel_Update_Success_Test() { MVoxAuditingEntities.AllInstances.BatchesGet = (c) => { FakeObjectSet <Batch> objectSet = new FakeObjectSet <Batch>(); objectSet.Add(new Batch() { BatchID = 1, BatchNumber = "Test", MessageClientID = 1, StartDate = DateTime.Now }); return(objectSet); }; MVoxAuditingEntities.AllInstances.SaveChanges = (c) => { return(1); }; bool result = repository.Update(new Model.Batch(1, "Test") { ClientID = 1, FinishDate = DateTime.Now }); Assert.IsTrue(result); }
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 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(); }
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); }
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()); }
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. }
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); }
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); }
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); }
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 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); }
public void InitializationWithTestData() { Employee emp = new Employee(); FakeObjectSet<Employee> set = new FakeObjectSet<Employee>(new Employee[] { emp }); Assert.IsTrue(set.Contains(emp), "Constructor did not add supplied Employees to public Enumerator."); }
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); }
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 MyTestInitialize() { employeeObjectSet = new FakeObjectSet <Employee>(); mockDatabaseConext = new Mock <DatabaseContext>(); employeeBLL = new EmployeeBLL(mockDatabaseConext.Object); }
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()); }