public async Task should_remove_records_when_soldout_messages_contains_existing_ids()
        {
            const string itemSoldOutId           = "be05537d-5e80-45c1-bd8c-aa21c0f1251e";
            var          repository              = _cartContextFactory.GetCartRepository();
            var          itemSoldOutEventHandler = new ItemSoldOutEventHandler(repository);
            var          found = false;

            await itemSoldOutEventHandler.Handle(new ItemSoldOutEvent { Id = itemSoldOutId }, CancellationToken.None);

            foreach (var cartId in repository.GetCarts())
            {
                var cart = await repository.GetAsync(new Guid(cartId));

                found = cart.Items.Any(i => i.CartItemId.ToString() == itemSoldOutId);
            }

            found.ShouldBeTrue();
        }
Exemple #2
0
        public async Task should_remove_records_when_soldout_messages_contains_existing_ids()
        {
            string itemSoldOutId           = "be05537d-5e80-45c1-bd8c-aa21c0f1251e";
            var    context                 = new TestableMessageHandlerContext();
            var    repository              = _contextFactory.GetCartRepository();
            var    itemSoldOutEventHandler = new ItemSoldOutEventHandler(repository);
            bool   found = false;


            await itemSoldOutEventHandler.Handle(
                new ItemSoldOutEvent { Id = itemSoldOutId }, context);

            foreach (string cartId in repository.GetCarts())
            {
                var cart = await repository.GetAsync(new Guid(cartId));

                found = cart.Items.Any(i => i.CartItemId.ToString() == itemSoldOutId);
            }

            found.ShouldBeFalse();
        }
Exemple #3
0
        public async Task should_not_remove_records_when_soldout_message_contains_not_existing_id()
        {
            var context    = new TestableMessageHandlerContext();
            var repository = _contextFactory.GetCartRepository();
            var itemSoldOutEventHandler = new ItemSoldOutEventHandler(repository);
            var found = false;

            await itemSoldOutEventHandler.Handle(
                new ItemSoldOutEvent { Id = Guid.NewGuid().ToString() }, context);

            var cartsIds = repository.GetCarts();

            foreach (var cartId in cartsIds)
            {
                var cart = await repository.GetAsync(new Guid(cartId));

                found = cart.Items.Any(i => i.CartItemId.ToString() == "be05537d-5e80-45c1-bd8c-aa21c0f1251e");
            }

            found.ShouldBeTrue();
        }