Пример #1
0
        public async Task FindAsyncShouldReturnCorrectResultWithFilterAndOrder()
        {
            // Arrange

            var userManager = this.GetUserManagerMock();

            var firstBusiness = new Business {
                Id = 1, City = "First", Type = TypeBusiness.Cabin, Address = "test", PetType = PetType.AllDogs
            };
            var secondBusiness = new Business {
                Id = 2, City = "Second", Type = TypeBusiness.Cabin, Address = "test", PetType = PetType.AllDogs
            };
            var thirdBusiness = new Business {
                Id = 3, City = "Third", Type = TypeBusiness.Cabin, Address = "test", PetType = PetType.AllDogs
            };

            db.AddRange(firstBusiness, secondBusiness, thirdBusiness);

            await db.SaveChangesAsync();

            var businessService = new BusinessService(this.db, userManager.Object);

            // Act
            var result = await businessService.FindAsync("t");

            // Assert
            result
            .Should()
            .Match(r => r.ElementAt(0).Id == 3 &&
                   r.ElementAt(1).Id == 1)
            .And
            .HaveCount(2);
        }