Esempio n. 1
0
        public async Task GetSiteVariableAmountsAsync_Paging_Consistency()
        {
            var configuration = Configuration.GetConfiguration();

            using (var db = new WaDEContext(configuration))
            {
                for (var i = 0; i < 15; i++)
                {
                    await SiteVariableAmountsFactBuilder.Load(db);
                }
            }

            var filters = new SiteVariableAmountsFilters();

            var sut         = CreateSiteVariableAmountsAccessor();
            var baseResults = (await sut.GetSiteVariableAmountsAsync(filters, 0, 15)).Organizations.SelectMany(a => a.SiteVariableAmounts).Select(a => a.SiteVariableAmountId).ToList();

            for (var i = 0; i < 14; i++)
            {
                var pagedResults = await sut.GetSiteVariableAmountsAsync(filters, i, 2);

                var waterAllocations = pagedResults.Organizations.SelectMany(a => a.SiteVariableAmounts).Select(a => a.SiteVariableAmountId).ToList();
                waterAllocations.Should().HaveCount(2);
                waterAllocations.Should().BeEquivalentTo(baseResults.Skip(i).Take(2));
            }
        }
Esempio n. 2
0
        public async Task GetSiteVariableAmountsAsync_NoFilters()
        {
            var configuration = Configuration.GetConfiguration();
            SiteVariableAmountsFact siteVariableAmountsFact;

            using (var db = new WaDEContext(configuration))
            {
                siteVariableAmountsFact = await SiteVariableAmountsFactBuilder.Load(db);

                siteVariableAmountsFact.SiteVariableAmountId.Should().NotBe(0);
            }

            var filters = new SiteVariableAmountsFilters();

            var sut    = CreateSiteVariableAmountsAccessor();
            var result = await sut.GetSiteVariableAmountsAsync(filters, 0, int.MaxValue);

            result.TotalSiteVariableAmountsCount.Should().Be(1);
            result.Organizations.Should().HaveCount(1);

            var org = result.Organizations.Single();

            org.OrganizationId.Should().Be(siteVariableAmountsFact.OrganizationId);
            org.SiteVariableAmounts.Should().HaveCount(1);
            org.SiteVariableAmounts[0].SiteVariableAmountId.Should().Be(siteVariableAmountsFact.SiteVariableAmountId);
        }
Esempio n. 3
0
        public async Task GetSiteVariableAmountsAsync_Paging()
        {
            var configuration = Configuration.GetConfiguration();

            using (var db = new WaDEContext(configuration))
            {
                for (var i = 0; i < 15; i++)
                {
                    await SiteVariableAmountsFactBuilder.Load(db);
                }
            }

            var filters = new SiteVariableAmountsFilters();

            var alreadyRetrieved = new List <long>();

            for (var i = 1; i <= 5; i++)
            {
                var sut          = CreateSiteVariableAmountsAccessor();
                var pagedResults = await sut.GetSiteVariableAmountsAsync(filters, Utility.NthTriangle(i - 1), i);

                pagedResults.TotalSiteVariableAmountsCount.Should().Be(15);
                var waterAllocations = pagedResults.Organizations.SelectMany(a => a.SiteVariableAmounts).Select(a => a.SiteVariableAmountId).ToList();
                waterAllocations.Should().HaveCount(i);
                foreach (var waterAllocation in waterAllocations)
                {
                    alreadyRetrieved.Should().NotContain(waterAllocation);
                    alreadyRetrieved.Add(waterAllocation);
                }
            }

            alreadyRetrieved.Should().OnlyHaveUniqueItems().And.HaveCount(15);
        }
Esempio n. 4
0
        public async Task GetSiteVariableAmountsAsync_Paging_RequestAfterLast()
        {
            var configuration = Configuration.GetConfiguration();

            using (var db = new WaDEContext(configuration))
            {
                for (var i = 0; i < 3; i++)
                {
                    await SiteVariableAmountsFactBuilder.Load(db);
                }
            }

            var filters = new SiteVariableAmountsFilters();

            var sut          = CreateSiteVariableAmountsAccessor();
            var pagedResults = await sut.GetSiteVariableAmountsAsync(filters, 3, 10);

            pagedResults.TotalSiteVariableAmountsCount.Should().Be(3);
            var waterAllocations = pagedResults.Organizations.SelectMany(a => a.SiteVariableAmounts).Select(a => a.SiteVariableAmountId).ToList();

            waterAllocations.Should().HaveCount(0);
        }