Пример #1
0
        public async Task GetUserExcludedSellerPreferences_Should_Return_List_Of_Sellers_User_Has_Excluded()
        {
            // Arrange
            await _dbContext.Database.EnsureDeletedAsync();

            var listOfSellers = new List <tblSellers>();

            listOfSellers.Add(new tblSellersBuilder().WithId(1).WithName("Amazon").WithUrl("https://www.amazon.co.uk").Build());
            listOfSellers.Add(new tblSellersBuilder().WithId(2).WithName("Ebay").WithUrl("https://www.ebay.co.uk").Build());
            listOfSellers.Add(new tblSellersBuilder().WithId(3).WithName("Currys PC World").WithUrl("https://www.currys.co.uk").Build());
            _dbContext.tblSellers.AddRange(listOfSellers);

            var listOfExclSellers = new List <tblExcludedSellers>();

            listOfExclSellers.Add(new tblExcludedSellersBuilder().WithUsername(_username).WithSellerId(2).Build());
            listOfExclSellers.Add(new tblExcludedSellersBuilder().WithUsername(_username).WithSellerId(3).Build());
            _dbContext.tblExcludedSellers.AddRange(listOfExclSellers);

            await _dbContext.SaveChangesAsync();

            // Act
            var task   = _userSettingsService.GetUserExcludedSellerPreferences(_username);
            var result = task.Result;

            Assert.IsAssignableFrom <IEnumerable <UserSeller> >(result);
            Assert.Equal(2, result.Count());
        }