public void get_corresponding_document_for_a_given_language() { var versionRange = new VersionRange( fromVersion: version2, toVersion: version4 ); versionRange.AddDocument(spanishDocument); versionRange.AddDocument(englishDocument); var document = versionRange.GetDocumentIn("es-ES"); document.ShouldBeEquivalentTo(spanishDocument); }
public VersionRange Build() { var versionRange = new VersionRange(firstVersion, lastVersion).WithId(id); foreach (var document in documents) { versionRange.AddDocument(document); } return versionRange; }
public async Task save_documents_foreach_version_range_in_a_topic() { var versionRange = new VersionRange(fromVersion: version1, toVersion: version1).WithId("AnyVersionRangeId"); anyTopic.AddVersionRange(versionRange); versionRange.AddDocument( new Document("AnyTitle", "AnyDescription", "AnyContent", "es-ES").WithId("AnyDocumentId") ); await topicRepository.Save(anyTopic); var documentFromRepo = await GetDocumentById("AnyDocumentId"); Assert.That(documentFromRepo.Title, Is.EqualTo("AnyTitle")); Assert.That(documentFromRepo.Description, Is.EqualTo("AnyDescription")); Assert.That(documentFromRepo.Content, Is.EqualTo("AnyContent")); Assert.That(documentFromRepo.Language, Is.EqualTo("es-ES")); Assert.That(documentFromRepo.VersionRangeId, Is.EqualTo("AnyVersionRangeId")); }
public async Task delete_all_documents_for_each_of_its_product_versions_from_database() { var documentId = "DocumentId"; var document = new Document("Título", "Descripción", "Contenido", "es-ES").WithId(documentId); var versionRange = new VersionRange(anyVersion, anotherVersion) .WithId("VersionRangeId"); versionRange.AddDocument(document); var topic = new Topic("OpportunityId").WithId("TopicId"); topic.AddVersionRange(versionRange); await new SqlInserter(dbConnection).Insert(topic); await topicRepository.Delete(topic.TopicId); var documentFromDataBase = (await dbConnection.Query<object>(@"SELECT * FROM Document WHERE DocumentId = @DocumentId", new {DocumentId = documentId})) .FirstOrDefault(); documentFromDataBase.Should().BeNull(); }
public async Task removes_old_documents_for_given_topic() { var topic = new Topic("PapyrusId").WithId("TopicId"); var versionRange = new VersionRange(version1, version2) .WithId("VersionRangeId"); var document = new Document("Título", "Descripción", "Contenido", "es-ES").WithId("DocumentId"); versionRange.AddDocument(document); topic.AddVersionRange(versionRange); await sqlInserter.Insert(topic); var topicToUpdate = new Topic("PapyrusId").WithId("TopicId"); await sqlTopicRepository.Update(topicToUpdate); var oldDocument = (await dbConnection.Query<Document>(@"SELECT Title, Description, Content, Language FROM Document WHERE DocumentId = @DocumentId", new { DocumentId = "DocumentId" })).FirstOrDefault(); oldDocument.Should().BeNull(); }
public async Task a_list_with_topics_with_wildcard_as_to_version() { await InsertProductWithItsVersions(); var topic = new Topic(ProductId).WithId("AnyTopicId"); var firstVersionRange = new VersionRange(version1, new LastProductVersion()).WithId("AnyRangeId"); firstVersionRange.AddDocument(spanishDocument.WithId("AnyDocumentId")); topic.AddVersionRange(firstVersionRange); await sqlInserter.Insert(topic); var topicSummaries = await topicRepository.GetAllTopicsSummariesFor("es-ES"); topicSummaries.First().VersionName.Should().Be(LastProductVersion.Name); }
public async Task get_empty_list_if_there_are_no_documents() { await InsertProductWithItsVersions(); var topic = new Topic(ProductId).WithId("FirstTopicPapyrusId"); var firstVersionRange = new VersionRange(version1, version1).WithId("FirstVersionRangeId"); firstVersionRange.AddDocument(spanishDocument.WithId("AnyId")); topic.AddVersionRange(firstVersionRange); await sqlInserter.Insert(topic); var documents = await topicRepository.GetAllDocumentsFor(ProductId, version1.VersionName, EnglishLanguage); documents.Should().HaveCount(0); }
public async Task exportable_topic_for_a_given_version_and_language() { await InsertProductWithItsVersions(); var topic = new Topic(ProductId).WithId("FirstTopicPapyrusId"); var firstVersionRange = new VersionRange(version1, version1).WithId("FirstVersionRangeId"); var secondVersionRange = new VersionRange(version2, new LastProductVersion()).WithId("SecondVersionRangeId"); firstVersionRange.AddDocument(spanishDocument.WithId("AnyId")); secondVersionRange.AddDocument(new Document("Título", "Descripción", "Contenido", "es-ES").WithId("AnotherId")); topic.AddVersionRange(firstVersionRange); topic.AddVersionRange(secondVersionRange); await sqlInserter.Insert(topic); var documents = await topicRepository.GetAllDocumentsFor(ProductId, version1.VersionName, SpanishLanguage); documents.Should().HaveCount(1); var document = documents.First(); document.Title.Should().Be(spanishDocument.Title); document.Content.Should().Be(spanishDocument.Content); }
public async Task a_displayable_topic_with_documents_for_each_of_its_version_ranges() { await InsertProductWithAVersion(); var topic = new Topic(ProductId).WithId("FirstTopicPapyrusId"); var firstVersionRange = new VersionRange(version1, version1).WithId("FirstVersionRangeId"); spanishDocument.WithId("DocumentId"); firstVersionRange.AddDocument(spanishDocument); topic.AddVersionRange(firstVersionRange); await sqlInserter.Insert(topic); var editableTopic = await topicRepository.GetEditableTopicById("FirstTopicPapyrusId"); var editableVersionRange = editableTopic.VersionRanges.First(); editableVersionRange.Documents.Should().HaveCount(1); var editableDocument = editableVersionRange.Documents.First(); editableDocument.Title.Should().Be("Título"); editableDocument.Description.Should().Be("Descripción"); editableDocument.Content.Should().Be("Contenido"); editableDocument.Language.Should().Be(SpanishLanguage); }
public async Task save_documents_for_each_of_its_version_ranges() { var topic = new Topic("PapyrusId").WithId("TopicId"); await sqlInserter.Insert(topic); var versionRange = new VersionRange(version1, version2).WithId("VersionRangeId"); versionRange.AddDocument(new Document("Título", "Descripción", "Contenido", "es-ES").WithId("DocumentId")); topic.AddVersionRange(versionRange); await sqlTopicRepository.Update(topic); var newVersionRange = (await dbConnection.Query<Document>(@"SELECT Title, Description, Content, Language FROM Document WHERE VersionRangeId = @VersionRangeId", new { VersionRangeId = "VersionRangeId" })).FirstOrDefault(); newVersionRange.Title.Should().Be("Título"); newVersionRange.Description.Should().Be("Descripción"); newVersionRange.Content.Should().Be("Contenido"); newVersionRange.Language.Should().Be("es-ES"); }