main
 1using Machine.Specifications;
 2using solidware.financials.infrastructure;
 3using solidware.financials.messages;
 4using solidware.financials.service.handlers;
 5
 6namespace specs.unit.service.handlers
 7{
 8    public class StockPriceRequestQueryHandlerSpecs
 9    {
10        public abstract class concern
11        {
12            Establish context = () =>
13            {
14                bus = Create.dependency<ServiceBus>();
15                service = Create.dependency<StockPriceLookupService>();
16                sut = new StockPriceRequestQueryHandler(bus, service);
17            };
18
19            static protected StockPriceRequestQueryHandler sut;
20            static protected ServiceBus bus;
21            static protected StockPriceLookupService service;
22        }
23
24        public class when_looking_up_the_current_price_of_a_known_symbol : concern
25        {
26            Establish context = () =>
27            {
28                query = new StockPriceRequestQuery {Symbol = "ARX.TO"};
29                price = new CurrentStockPrice();
30                service.is_told_to(x => x.FindPriceFor("ARX.TO")).it_will_return(price);
31            };
32
33            Because of = () =>
34            {
35                sut.handle(query);
36            };
37
38            It should_publish_the_current_price = () =>
39            {
40                bus.was_told_to(x => x.publish(price));
41            };
42
43            static StockPriceRequestQuery query;
44            static CurrentStockPrice price;
45        }
46    }
47}