public static async Task CreateAndClearBasket(this BasketItemsRepository repository, int userId)
        {
            // Simulate creation of basket
            await repository.AddItem(userId, new BasketItem(1, 2));

            await repository.ClearItems(userId);
        }
Пример #2
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);
        }
Пример #3
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);
        }