Пример #1
0
        public async void GetSearchedAdPositive()
        {
            // Arrange
            var advertisementRepository = new Mock <IAdvertisementReposiotry>();

            advertisementRepository.Setup(u => u.GetQueriedAds(It.IsAny <AdQueryOptions>()))
            .ReturnsAsync(new List <Advertisement>()
            {
                new Advertisement()
                {
                    Id   = 1,
                    Item = new Game()
                }
            }).Verifiable();

            var service = new AdvertisementService(advertisementRepository.Object, null, null, null, null, null, null, null, _fixture.Mapper);

            // Act
            var result = await service.GetAdvetisements(new AdQueryOptions()
            {
                Sort    = "price",
                Desc    = true,
                Systems = new int[0],
                Genres  = new int[0]
            });

            var ads = result.Payload as List <AdvertisementWithoutItemDto>;

            // Assert
            Assert.NotNull(ads);
            Assert.Single(ads);
            advertisementRepository.Verify();
        }