Exemple #1
0
 public VersionRange(ProductVersion fromVersion, ProductVersion toVersion)
 {
     if (fromVersion.Release > toVersion.Release) throw new VersionRangeCannotBeDescendentException();
     FromVersion = fromVersion;
     ToVersion = toVersion;
     Documents = new Documents.Documents();
 }
 public VersionRangeBuilder(string id, ProductVersion firstVersion, ProductVersion lastVersion)
 {
     this.id = id;
     this.firstVersion = firstVersion;
     this.lastVersion = lastVersion;
     this.documents = new List<Document>();
 }
        public async Task a_topic_summary_list_distincting_by_topic_showing_last_valid_version_name() {
            await InsertProductWithItsVersions();
            var version3 = new ProductVersion("thirdVersion", "3.0", DateTime.Today);
            await InsertProductVersion(version3, ProductId);
            var topic = new TopicBuilder(ProductId, "AnyTopicId")
                                .WithVersionRanges(
                                    new VersionRangeBuilder("FirstRange", version1, version2)
                                            .WithDocuments(
                                                spanishDocument.WithId("FirstDocument")),
                                    new VersionRangeBuilder("SecondRange", version3, version3)
                                            .WithDocuments(
                                                new Document("Any", "Any", "Any", "es-ES").WithId("ThirdDocument"))
                                ).Build();
            await sqlInserter.Insert(topic);

            var topicSummaries = await topicRepository.GetAllTopicsSummariesFor("es-ES");

            topicSummaries.Should().Contain(t => t.VersionName == "3.0");
        }
 private async Task InsertProductVersion(ProductVersion productVersion, string productId) {
     await dbConnection.Execute(@"INSERT INTO ProductVersion(VersionId, VersionName, ProductId, Release) 
                         VALUES (@VersionId, @VersionName, @ProductId, @Release);",
         new {
             VersionId = productVersion.VersionId,
             VersionName = productVersion.VersionName,
             ProductId = productId,
             Release = productVersion.Release
         });
 }
        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 get_last_version_for_a_given_product() {
            var thirdVersion = new ProductVersion("ThirdVersionId", "3.0", DateTime.Today.AddDays(-1));
            var papyrusVersions = new List<ProductVersion>
            {
                new ProductVersion("FirstVersionId", "1.0", DateTime.Today.AddDays(-3)),
                new ProductVersion("SecondVersionId", "2.0", DateTime.Today.AddDays(-2)),
                thirdVersion,
            };
            foreach (var papyrusVersion in papyrusVersions) {
                await InsertProductVersion(papyrusVersion, "PapyrusId");
            }

            var lastVersion = await sqlProductRepository.GetLastVersionForProduct("PapyrusId");

            lastVersion.ShouldBeEquivalentTo(thirdVersion);
        }
 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);
 }