public void TestUpdateEditionNote() { var unitOfWorkProvider = CreateMockUnitOfWorkProvider(); var resourceRepository = new MockResourceRepository(unitOfWorkProvider); var bookData = new BookData { ContainsEditionNote = true }; var subtask = new UpdateEditionNoteSubtask(resourceRepository); subtask.UpdateEditionNote(0, 155, 1, bookData); subtask.UpdateEditionNote(40, 155, 1, bookData); var createdEditionNotes = resourceRepository.CreatedObjects.OfType <EditionNoteResource>().ToList(); var updatedEditionNotes = resourceRepository.UpdatedObjects.OfType <EditionNoteResource>().ToList(); Assert.AreEqual(0, updatedEditionNotes.Count); Assert.AreEqual(2, createdEditionNotes.Count); var editionNote1 = createdEditionNotes.First(x => x.Resource.Project.Id == 0); var editionNote2 = createdEditionNotes.First(x => x.Resource.Project.Id == 40); Assert.AreEqual(1, editionNote1?.VersionNumber); Assert.AreEqual(2, editionNote2?.VersionNumber); Assert.IsNotNull(editionNote1?.BookVersion); }
protected override void ExecuteWorkImplementation() { m_projectId = m_nullableProjectId ?? throw new InvalidOperationException("Required ProjectId wasn't set in ResourceSessionDirector"); // Updating Project data is not required, because data has been already updated m_importedResourceVersionIds = new List <long>(); m_bookVersionId = new UpdateBookVersionSubtask(m_resourceRepository).UpdateBookVersion(m_projectId, m_userId, m_bookData); var updateEditionNoteSubtask = new UpdateEditionNoteSubtask(m_resourceRepository); var editionNoteVersionId = updateEditionNoteSubtask.UpdateEditionNote(m_projectId, m_bookVersionId, m_userId, m_bookData); if (editionNoteVersionId != null) { m_importedResourceVersionIds.Add(editionNoteVersionId.Value); } //TODO update: transformations new UpdateAuthorsSubtask(m_projectRepository, m_personRepository).UpdateAuthors(m_projectId, m_bookData); new UpdateResponsiblePersonSubtask(m_projectRepository, m_personRepository).UpdateResponsiblePersonList(m_projectId, m_bookData); var updateMetadataSubtask = new UpdateMetadataSubtask(m_metadataRepository); updateMetadataSubtask.UpdateMetadata(m_projectId, m_userId, m_bookData); // Categories are not updated from import (XMD doesn't contain detailed categorization) //new UpdateCategoriesSubtask(m_categoryRepository).UpdateCategoryList(m_projectId, m_bookData); new UpdateLiteraryKindsSubtask(m_catalogValueRepository, m_metadataRepository).UpdateLiteraryKinds(m_projectId, m_bookData); new UpdateLiteraryGenresSubtask(m_catalogValueRepository, m_metadataRepository).UpdateLiteraryGenres(m_projectId, m_bookData); new UpdateLiteraryOriginalsSubtask(m_catalogValueRepository, m_metadataRepository).UpdateLiteraryOriginals(m_projectId, m_bookData); new UpdateKeywordsSubtask(m_projectRepository, m_catalogValueRepository).UpdateKeywords(m_projectId, m_bookData); var updateTermsSubtask = new UpdateTermsSubtask(m_resourceRepository); updateTermsSubtask.UpdateTerms(m_projectId, m_bookData); var updatePagesSubtask = new UpdatePagesSubtask(m_resourceRepository); updatePagesSubtask.UpdatePages(m_projectId, m_bookVersionId, m_userId, m_bookData, updateTermsSubtask.ResultTermCache); m_importedResourceVersionIds.AddRange(updatePagesSubtask.ImportedResourceVersionIds); var updateChaptersSubtask = new UpdateChaptersSubtask(m_resourceRepository); updateChaptersSubtask.UpdateChapters(m_projectId, m_userId, m_bookData, updatePagesSubtask.ResultPageResourceList); m_importedResourceVersionIds.AddRange(updateChaptersSubtask.ImportedResourceVersionIds); var updateHeadwordsSubtask = new UpdateHeadwordsSubtask(m_resourceRepository); updateHeadwordsSubtask.UpdateHeadwords(m_projectId, m_bookVersionId, m_userId, m_bookData, updatePagesSubtask.ResultPageResourceList); m_importedResourceVersionIds.AddRange(updateHeadwordsSubtask.ImportedResourceVersionIds); var updateTracksSubtask = new UpdateTracksSubtask(m_resourceRepository); updateTracksSubtask.UpdateTracks(m_projectId, m_userId, m_bookData); updateTracksSubtask.UpdateFullBookTracks(m_projectId, m_userId, m_bookData); m_importedResourceVersionIds.AddRange(updateTracksSubtask.ImportedResourceVersionIds); new UpdateHistoryLogSubtask(m_projectRepository).UpdateHistoryLog(m_projectId, m_userId, m_message, m_bookData); }