Пример #1
0
        public void Should_Send_Event_To_Handlers()
        {
            var @event   = new WhateverNotification("Ack");
            var mediator = new Own.Mediator();

            mediator.Publish(@event);

            WhateverNotificationHandler.ReceivedMessage.Should().Be("Ack");
            OtherNotificationHandler.ReceivedMessage.Should().Be("Ack");
        }
Пример #2
0
        public void Should_Buy_Product()
        {
            var product           = new Product("Product A", 10, 5.0);
            var productRepository = new ProductRepository();

            productRepository.Insert(product);

            var request  = new ProductBuyerRequest(product.Id, 2);
            var mediator = new Own.Mediator();

            mediator.Send(request);

            product = productRepository.Get(p => p.Id == product.Id).FirstOrDefault();

            product.Quantity.Should().Be(8);
        }