コード例 #1
0
        public async Task AllAsyncWithCategoryIdShouldReturnAllItemsWithTheirPictures()
        {
            // Arrange
            var db = this.Context;

            this.PopulateData(db);

            var advertisementsService = new AdvertisementService(db);
            var categoryId            = 1;

            // Act
            var result = await advertisementsService.AllAsync(categoryId);

            // Assert
            result
            .Advertisements
            .Select(a => a.Id)
            .ToList()
            .ElementAt(0)
            .Should()
            .Be(2);

            result
            .Advertisements
            .Select(a => a.Id)
            .ToList()
            .ElementAt(1)
            .Should()
            .Be(1);

            result
            .Advertisements
            .Select(a => a.Id)
            .ToList()
            .Should()
            .HaveCount(2);

            result
            .Pictures
            .ElementAt(0)
            .Should()
            .Be(DataConstants.ImgDefoutNotFound);

            result
            .Pictures
            .ElementAt(1)
            .Should()
            .Be(DataConstants.ImgDefoutNotFound);

            result
            .Pictures
            .Should()
            .HaveCount(2);
        }