Exemplo n.º 1
0
        public async Task ShouldChangePrice(
            TestableContext context,
            BasketItemIndex handler
            )
        {
            context.Processor.Plan <eShop.Basket.Basket.Services.BasketsUsingProduct, Guid[]>(new eShop.Basket.Basket.Services.BasketsUsingProduct {
                ProductId = context.Id()
            }).Response(new Guid[] { context.Id() });
            context.App.Plan <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Exists(new Models.BasketItemIndex
            {
                ProductPrice = 1
            });

            var @event = context.Create <Catalog.Product.Events.PriceUpdated>(x =>
            {
                x.ProductId = context.Id();
                x.Price     = 2;
            });

            await handler.Handle(@event, context).ConfigureAwait(false);

            context.App.Check <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Updated(x =>
                                                                                                                            x.ProductPrice == 2
                                                                                                                            );
        }
Exemplo n.º 2
0
        public async Task ShouldAddItem(
            TestableContext context,
            BasketItemIndex handler
            )
        {
            context.App.Plan <Catalog.Product.Models.CatalogProductIndex>(context.Id()).Exists(new Catalog.Product.Models.CatalogProductIndex
            {
                Id                 = context.Id(),
                Name               = "test",
                Description        = "test",
                PictureContents    = "test",
                PictureContentType = "test",
                Price              = 100
            });

            var @event = context.Create <Entities.Item.Events.ItemAdded>(x =>
            {
                x.BasketId  = context.Id();
                x.ProductId = context.Id();
            });

            await handler.Handle(@event, context).ConfigureAwait(false);

            context.App.Check <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Added(x =>
                                                                                                                          x.ProductPrice == 100 &&
                                                                                                                          x.ProductName == "test" &&
                                                                                                                          x.ProductDescription == "test"
                                                                                                                          );
        }
Exemplo n.º 3
0
        public async Task ShouldRemoveItem(
            TestableContext context,
            BasketItemIndex handler
            )
        {
            context.App.Plan <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Exists();

            var @event = context.Create <Entities.Item.Events.ItemRemoved>(x =>
            {
                x.BasketId  = context.Id();
                x.ProductId = context.Id();
            });

            await handler.Handle(@event, context).ConfigureAwait(false);

            context.App.Check <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Deleted();
        }
Exemplo n.º 4
0
        public async Task ShouldChangeQuantity(
            TestableContext context,
            BasketItemIndex handler
            )
        {
            context.App.Plan <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Exists(new Models.BasketItemIndex
            {
                Quantity = 1
            });

            var @event = context.Create <Entities.Item.Events.QuantityUpdated>(x =>
            {
                x.BasketId  = context.Id();
                x.ProductId = context.Id();
                x.Quantity  = 2;
            });

            await handler.Handle(@event, context).ConfigureAwait(false);

            context.App.Check <Models.BasketItemIndex>(BasketItemIndex.ItemIdGenerator(context.Id(), context.Id())).Updated(x =>
                                                                                                                            x.Quantity == 2
                                                                                                                            );
        }