public void SaveFullRecord() { var userId = m_mockDataManager.GetOrCreateUser(); var externalRepositoryId = m_mockDataManager.CreateExternalRepository("", new List <FilteringExpressionContract>()); new SaveImportedDataWork(m_projectRepository, m_metadataRepository, m_catalogValueRepository, m_personRepository, m_permissionRepository, m_importedRecord, userId, externalRepositoryId, m_mockDataManager.GetOrCreateBookType(), new List <int>()).Execute(); Assert.AreNotEqual(null, m_importedRecord.ProjectId); var project = m_metadataRepository.GetAdditionalProjectMetadata(m_importedRecord.ProjectId, true, true, false, true, true, true, false); var externalRepository = m_externalRepositoryRepository.GetExternalRepository(externalRepositoryId); Assert.AreEqual(m_importedRecord.ImportedProject.ProjectMetadata.Title, project.Name); Assert.AreEqual(string.Format(externalRepository.UrlTemplate, m_importedRecord.ImportedProject.Id), project.OriginalUrl); Assert.AreEqual(userId, project.CreatedByUser.Id); Assert.AreEqual(1, project.Snapshots.Count); CollectionAssert.AreEquivalent(m_importedRecord.ImportedProject.Keywords.ToList(), project.Keywords.Select(x => x.Text).ToList()); CollectionAssert.AreEquivalent(m_importedRecord.ImportedProject.LiteraryGenres.ToList(), project.LiteraryGenres.Select(x => x.Name).ToList()); Assert.AreEqual(m_importedRecord.ImportedProject.Authors.Count, project.Authors.Count); Assert.AreEqual(m_importedRecord.ImportedProject.Authors.First().FirstName, project.Authors.First().OriginalAuthor.FirstName); Assert.AreEqual(m_importedRecord.ImportedProject.Authors.First().LastName, project.Authors.First().OriginalAuthor.LastName); var metadataResource = m_metadataRepository.GetLatestMetadataResource(m_importedRecord.ProjectId); Assert.AreEqual(m_importedRecord.ImportedProject.ProjectMetadata.Title, metadataResource.Title); Assert.AreEqual(m_importedRecord.ImportedProject.ProjectMetadata.PublisherText, metadataResource.PublisherText); Assert.AreEqual(m_importedRecord.ImportedProject.ProjectMetadata.PublishDate, metadataResource.PublishDate); Assert.AreEqual(m_importedRecord.ImportedProject.ProjectMetadata.PublishPlace, metadataResource.PublishPlace); var importedProjectMetadata = m_importedProjectMetadataManager.GetImportedProjectMetadataByExternalId(m_importedRecord.ExternalId); Assert.AreNotEqual(null, importedProjectMetadata.Id); Assert.AreEqual(m_importedRecord.ExternalId, importedProjectMetadata.ExternalId); Assert.AreEqual(project.Id, importedProjectMetadata.Project.Id); }
public void SaveImportedRecord() { var userId = m_mockDataManager.GetOrCreateUser(); var externalRepositoryId = m_mockDataManager.CreateExternalRepository("", new List <FilteringExpressionContract>()); var historyId = m_mockDataManager.CreateImportHistory(); var info = new RepositoryImportProgressInfo(externalRepositoryId, "Test"); m_importedProjectManager.SaveImportedProject(m_importedRecord, userId, externalRepositoryId, m_mockDataManager.GetOrCreateBookType(), new List <int>(), historyId, info); Assert.AreEqual(false, info.IsCompleted); Assert.AreEqual(0, info.FailedProjectsCount); Assert.AreEqual(1, info.ProcessedProjectsCount); Assert.AreEqual(null, info.FaultedMessage); Assert.AreNotEqual(null, m_importedRecord.ProjectId); var project = m_metadataRepository.GetAdditionalProjectMetadata(m_importedRecord.ProjectId, true, true, false, true, true, true, false); var snapshot = m_projectRepository.GetLatestSnapshot(m_importedRecord.ProjectId); var importedRecordMetadata = m_importedRecordMetadataRepository.InvokeUnitOfWork(x => x.GetImportedRecordMetadataBySnapshot(snapshot.Id)); var importedProjectMetadata = m_importedProjectMetadataRepository.InvokeUnitOfWork(x => x.GetImportedProjectMetadata(m_importedRecord.ExternalId)); Assert.AreNotEqual(null, importedProjectMetadata.Id); Assert.AreEqual(m_importedRecord.ExternalId, importedProjectMetadata.ExternalId); Assert.AreEqual(project.Id, importedProjectMetadata.Project.Id); Assert.AreEqual(historyId, importedRecordMetadata.LastUpdate.Id); Assert.AreEqual(null, importedRecordMetadata.LastUpdateMessage); Assert.AreEqual(importedProjectMetadata.Id, importedRecordMetadata.ImportedProjectMetadata.Id); }