示例#1
0
        public DispatcherTests()
        {
            Events   = Substitute.For <IEventStore>();
            Services = Substitute.For <IServiceProvider>();
            Services.GetService(typeof(Domains.Airline.FlightReservation)).Returns(new Domains.Airline.FlightReservation());
            var resv = new AggregateModel(typeof(Domains.Airline.FlightReservation));

            resv.SetFactoryHandler("Create");
            resv.AddCommandHandler("Cancel");
            Dispatcher = new Dispatcher(new BoundedContextModel(new[] { resv }), Events, Services);
        }
        public AggregateModelBuilder <T> Executes <TCommand>(Expression <Func <TCommand, string> > correlationAccessor)
        {
            var id = new Func <object, string>((obj) => {
                var expr = correlationAccessor.Body as MemberExpression;
                var prop = expr.Member as PropertyInfo;
                return((string)prop.GetValue(obj));
            });

            _model.AddCommandHandler(new CommandHandlerModel(FindMethodByParameter(typeof(TCommand)), new CommandModel(typeof(TCommand), new AggregateCorrelation(id))));
            return(this);
        }
 public AggregateModelTests()
 {
     Model = new AggregateModel(typeof(Domains.Airline.FlightReservation));
     Model.SetFactoryHandler(new CommandHandlerModel(Model.Type.GetMethods().Single(c => c.Name == "Create")));
     Model.AddCommandHandler(new CommandHandlerModel(Model.Type.GetMethods().Single(c => c.Name == "Cancel")));
 }