protected override long ExecuteWorkImplementation() { var projectType = (ProjectTypeEnum)m_projectType; var updateProjectSubtask = new UpdateProjectSubtask(m_projectRepository); var projectId = updateProjectSubtask.UpdateProject(m_nullableProjectId, m_userId, m_bookData, projectType); return(projectId); }
public void TestUpdateProject() { var unitOfWorkProvider = CreateMockUnitOfWorkProvider(); var bookData = new BookData { BookXmlId = "external-id", Title = "title" }; var projectRepository = new MockProjectRepository(unitOfWorkProvider); var subtask = new UpdateProjectSubtask(projectRepository); long?projectId = 12; subtask.UpdateProject(projectId, 1, bookData, ProjectTypeEnum.Research); Assert.AreEqual(1, projectRepository.UpdatedObjects.Count); Assert.AreEqual(0, projectRepository.CreatedObjects.Count); var updatedProject = (Project)projectRepository.UpdatedObjects.First(); Assert.AreEqual(bookData.BookXmlId, updatedProject.ExternalId); projectRepository = new MockProjectRepository(unitOfWorkProvider) { CanFindProjectByExternalId = true }; subtask = new UpdateProjectSubtask(projectRepository); var dbProjectId = subtask.UpdateProject(null, 1, bookData, ProjectTypeEnum.Research); Assert.AreEqual(0, projectRepository.CreatedObjects.Count); Assert.AreEqual(0, projectRepository.UpdatedObjects.Count); Assert.AreEqual(MockProjectRepository.GetProjectIdValue, dbProjectId); projectRepository = new MockProjectRepository(unitOfWorkProvider) { CanFindProjectByExternalId = false }; subtask = new UpdateProjectSubtask(projectRepository); subtask.UpdateProject(null, 1, bookData, ProjectTypeEnum.Research); Assert.AreEqual(1, projectRepository.CreatedObjects.Count); Assert.AreEqual(0, projectRepository.UpdatedObjects.Count); var createdProject = (Project)projectRepository.CreatedObjects.First(); Assert.AreEqual(bookData.BookXmlId, createdProject.ExternalId); }