private async Task AddWebsitesFor(Product product, List<string> languages) { foreach (var version in product.Versions) { foreach (var language in languages) { var website = await CreateWebsiteWithAllDocumentsFor(product, version, language); if (website.HasNotDocuments()) continue; websitesCollection.Add(website); } } }
public async Task fill_product_name() { var versionsNames = VersionNames(LastVersionName); var papyrus = new Product("PapyrusId", "Papyrus", VersionsFrom(versionsNames)); topicRepo.GetAllDocumentsFor(papyrus.Id, LastVersionName, English) .Returns(AsyncDocumentsList(englishDocument)); var websites = await websiteConstructor.Construct(papyrus, Languages(English)); websites.First().ProductName.Should().Be(papyrus.Name); }
public async Task not_create_website_when_there_are_no_document_available() { var versionsNames = VersionNames(LastVersionName); var opportunity = new Product("OpportunityId", "Opportunity", VersionsFrom(versionsNames)); topicRepo.GetAllDocumentsFor(opportunity.Id, LastVersionName, Spanish) .Returns(Task.FromResult(new List<ExportableDocument>())); var websites = await websiteConstructor.Construct(opportunity, Languages(Spanish)); websites.Should().BeEmpty(); }
public virtual async Task<WebsiteCollection> Construct(Product product, List<string> languages) { var websites = new WebsiteCollection(); foreach (var version in product.Versions) { foreach (var language in languages) { var website = await CreateWebsiteWithAllDocumentsFor(product, version, language); if (website.HasNotDocuments()) continue; websites.Add(website); } } return websites; }
public async Task construct_a_website_with_documents_associated_to_given_product_and_version() { var versionsNames = VersionNames(LastVersionName); var opportunity = new Product("OpportunityId", "Opportunity", VersionsFrom(versionsNames)); topicRepo.GetAllDocumentsFor(opportunity.Id, LastVersionName, Spanish) .Returns(AsyncDocumentsList(englishDocument)); var websites = await websiteConstructor.Construct(opportunity, Languages(Spanish)); var websiteDocument = websites.First().Documents.First(); websiteDocument.Content.Should().Be(EnglishContent); websiteDocument.Title.Should().Be(EnglishTitle); }
public async Task gets_range_that_goes_from_first_version_to_the_latest_one() { var versions = new List<ProductVersion> { new ProductVersion("FirstVersionId", "1.0", DateTime.Today.AddDays(-3)), new ProductVersion("SecondVersionId", "2.0", DateTime.Today.AddDays(-2)), new ProductVersion("ThirdVersionId", "3.0", DateTime.Today.AddDays(-1)), }; var product = new Product("PapyrusId", "Papyrus", versions); await InsertProduct(product); var fullRange = await sqlProductRepository.GetFullVersionRangeForProduct(product.Id); fullRange.FirstVersionId.Should().Be("FirstVersionId"); fullRange.LatestVersionId.Should().Be("ThirdVersionId"); }
private async Task InsertProductVersions(Product product) { foreach (var productVersion in product.Versions) { await InsertProductVersion(productVersion, product.Id); } }
private async Task InsertProduct(Product product) { await dbConnection.Execute(@"INSERT INTO Product(ProductId, ProductName) VALUES (@ProductId, @ProductName);", new { ProductId = product.Id, ProductName = product.Name, }); await InsertProductVersions(product); }
public async Task get_all_versions_names() { var version1 = new ProductVersion("AnyID", "1", DateTime.Today.AddDays(-20)); var version2 = new ProductVersion("AnyOtherID", "2", DateTime.Today); var versions = new List<ProductVersion> { version1, version2 }; var product = new Product("OpportunityID", "Opportunity", versions); await InsertProduct(product); var versionsNames = await sqlProductRepository.GetAllVersionNames(); versionsNames.Should().BeEquivalentTo(versions.Select(v => v.VersionName)); }
public async Task gets_all_versions_for_a_given_product() { var papyrusVersions = new List<ProductVersion> { new ProductVersion("FirstVersionId", "1.0", DateTime.Today.AddDays(-3)), new ProductVersion("SecondVersionId", "2.0", DateTime.Today.AddDays(-2)), }; var product = new Product("PapyrusId", "Papyrus", papyrusVersions); await InsertProduct(product); var versions = await sqlProductRepository.GetAllVersionsFor("PapyrusId"); versions.ShouldAllBeEquivalentTo(papyrusVersions); }
private async Task<WebSite> CreateWebsiteWithAllDocumentsFor(Product product, ProductVersion version, string language) { var documents = await topicRepo.GetAllDocumentsFor(product.Id, version.VersionName, language); return new WebSite(documents, product.Name, language, version.VersionName); }