Example #1
0
        public async Task AllAsyncShouldReturnCorrectAnimalsByPages()
        {
            var db = DbInfrastructure.GetDatabase();

            for (var i = 0; i < 50; i++)
            {
                await db.AddAsync(new Animal
                {
                    Name = $"Some random name {i}"
                });
            }

            await db.SaveChangesAsync();

            var animalService = new AnimalService(db);

            for (var i = 0; i < 10; i++)
            {
                var animals = await animalService.AllAsync(i + 1);

                animals
                .Should()
                .HaveCount(WebConstants.AnimalsPerPage);

                animals
                .Should()
                .BeInAscendingOrder(a => a.AnimalClass);
            }

            var animalsFromNonExistingPage = await animalService.AllAsync(11);

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