public void Initialize()
 {
     sqlInserter = new SqlInserter(dbConnection);
     topicRepository = new SqlTopicQueryRepository(dbConnection);
     TruncateDataBase().GetAwaiter().GetResult();
     spanishDocument = new Document("Título", "Descripción", "Contenido", SpanishLanguage);
     englishDocument = new Document("Title", "Description", "Content", EnglishLanguage);
 }
 private async Task InsertDocumentForVersionRange(Document document, VersionRange versionRange)
 {
     await connection.Execute(@"INSERT INTO Document(DocumentId, Title, Description, Content, Language, VersionRangeId)
                                             VALUES(@DocumentId, @Title, @Description, @Content, @Language, @VersionRangeId);",
         new
         {
             DocumentId = document.DocumentId,
             Title = document.Title,
             Description = document.Description,
             Content = document.Content,
             Language = document.Language,
             VersionRangeId = versionRange.VersionRangeId
         });
 }
 public void InitializeDocuments()
 {
     spanishDocument = new Document(
         title: "Título",
         description: "Descripción",
         content: "Contenido",
         language: "es-ES"
     );
     englishDocument = new Document(
         title: "Title",
         description: "Description",
         content: "Content",
         language: "en-GB"
     );
 }
        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();
        }
Exemple #6
0
 public void AddDocument(Document document)
 {
     Documents.Add(document);
 }
 private static void GivenAWebApiWithADocumentServiceWhichWhenGettingAllDocumentsReturns(Document[] expectedDocumentsList)
 {
     var documentService = SubstituteForDocumentService();
     documentService.AllDocuments().Returns(
         Task.FromResult(expectedDocumentsList)
         );
     WebApiConfig.Container.RegisterInstance(documentService);
 }
 private void GivenAWebApiWithADocumentServiceWhichWhenTryingToGetADocumentReturns(Document document)
 {
     documentService.GetDocumentById(AnyId).Returns(
         Task.FromResult(document)
         );
     WebApiConfig.Container.RegisterInstance(documentService);
 }