protected async Task UpdateItemNotInBasketAndAssert(BasketItemsRepository repository)
        {
            var updateResult = await repository.UpdateItem(UserId, new BasketItem(1, 2));

            updateResult.IsSuccessful.Should().Be(true);
            updateResult.ErrorMessage.Should().BeEmpty();

            var getResult = await repository.GetBasketItems(UserId);

            getResult.IsSuccessful.Should().Be(true);
            getResult.ErrorMessage.Should().BeEmpty();
            getResult.Item.Count().Should().Be(1);
            getResult.Item.ElementAt(0).ItemId.Should().Be(1);
            getResult.Item.ElementAt(0).Quantity.Should().Be(2);
        }
        protected async Task UpdateItemInBasketToZeroQuantityAndAssert(BasketItemsRepository repository)
        {
            await repository.UpdateItem(UserId, new BasketItem(1, 1));

            var updateResult = await repository.UpdateItem(UserId, new BasketItem(1, 0));

            updateResult.IsSuccessful.Should().Be(true);
            updateResult.ErrorMessage.Should().BeEmpty();

            var getResult = await repository.GetBasketItems(UserId);

            getResult.IsSuccessful.Should().Be(true);
            getResult.ErrorMessage.Should().BeEmpty();
            getResult.Item.Count().Should().Be(0);
        }
Esempio n. 3
0
        protected async Task AddExistingItemAndAssert(BasketItemsRepository repository)
        {
            await repository.AddItem(UserId, new BasketItem(2, 1));

            var addResult = await repository.AddItem(UserId, new BasketItem(2, 3));

            addResult.IsSuccessful.Should().Be(true);
            addResult.ErrorMessage.Should().BeEmpty();

            var getResult = await repository.GetBasketItems(UserId);

            getResult.IsSuccessful.Should().Be(true);
            getResult.ErrorMessage.Should().BeEmpty();
            getResult.Item.Count().Should().Be(1);
            getResult.Item.ElementAt(0).ItemId.Should().Be(2);
            getResult.Item.ElementAt(0).Quantity.Should().Be(3);
        }
Esempio n. 4
0
        protected async Task AddNewItemAndAssertItWasAdded(BasketItemsRepository repository)
        {
            var addResult = await repository.AddItem(UserId, new BasketItem(2, 1));

            addResult.IsSuccessful.Should().Be(true);
            addResult.Item.Count.Should().Be(1);
            addResult.Item[0].ItemId.Should().Be(2);
            addResult.Item[0].Description.Should().NotBe("Item description could not be found");
            addResult.Item[0].Price.Should().NotBe(-1);
            addResult.ErrorMessage.Should().BeEmpty();

            var getResult = await repository.GetBasketItems(UserId);

            getResult.IsSuccessful.Should().Be(true);
            getResult.ErrorMessage.Should().BeEmpty();
            getResult.Item.Count().Should().Be(1);
            getResult.Item.ElementAt(0).ItemId.Should().Be(2);
            getResult.Item.ElementAt(0).Quantity.Should().Be(1);
        }