public void Should_create_Result()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            var sut   = data.AsQueryable().ToResult(new Params());

            Assert.AreEqual(total, sut.Total);
        }
        public void Should_create_Result_without_Total()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            var sut   = data.AsQueryable().ToResultWithoutTotal(new Params());

            Assert.IsNotNull(sut);
        }
        public void Should_return_total()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            var sut   = new Result <Dummy>(new Params(), data.AsQueryable());

            Assert.AreEqual(total, sut.Total);
        }
        public void Should_return_correct_page_if_requested_page_not_available()
        {
            var data = new Faker <Dummy>().Generate(100);
            var sut  = new Result <Dummy>(new Params {
                Count = 200, Page = 2
            }, data.AsQueryable());

            Assert.AreEqual(1, sut.Page);
        }
        public void Should_create_ResultWithoutTotal_to_less_results()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            var sut   = data.AsQueryable().ToResultWithoutTotal(new Params {
                Page = 1, Count = 10000
            });

            Assert.AreEqual(100, sut.Data.Count());
        }
        public void Should_return_correct_total_if_count_bigger_than_total()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            var sut   = new Result <Dummy>(new Params {
                Count = 200, Page = 2
            }, data.AsQueryable());

            Assert.AreEqual(total, sut.Total);
        }
        public void Should_return_total_with_paging()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            var sut   = new Result <Dummy>(new Params {
                Count = 10, Page = 2
            }, data.AsQueryable());

            Assert.AreEqual(total, sut.Total);
        }
        public void Should_create_ResultWithoutTotal_with_first_page()
        {
            var total = 100;
            var data  = new Faker <Dummy>().Generate(total);
            // We request a none existing page, this should fallback in returning the first page
            var sut = data.AsQueryable().ToResultWithoutTotal(new Params {
                Page = 1000, Count = 10
            });

            Assert.AreEqual(1, sut.Page);
            Assert.AreEqual(10, sut.Data.Count());
        }
        public void Should_not_page_if_unchecked()
        {
            // Arrange
            var data = new Faker <Dummy>().Generate(13);
            var ps   = new Params {
                Page = 2, Count = 10
            };
            // Act
            var sut = new Result <Dummy>(ps, data.AsQueryable(), page: false);

            // Assert
            Assert.AreEqual(data.Count(), sut.Data.Count());
        }
Esempio n. 10
0
        public void Should_map_data()
        {
            var data = new Faker <Dummy>().Generate(2);
            var ps   = new Params {
                Count = 10, Page = 1
            };
            var sut = new Result <Dummy>(ps, data.AsQueryable())
                      .Select(entry => new DummyDTO {
                Name = entry.Name, Length = (entry.Name ?? "").Length
            });

            Assert.IsInstanceOf(typeof(DummyDTO), sut.Data.First());
        }
Esempio n. 11
0
        public async Task <IQueryable <Tenant> > GetTenants()
        {
            var data = new Faker <Tenant>().Generate(50);

            return(data.AsQueryable());
        }