public void CreateProject_Creates_An_Aggregate_And_A_CommandCreated_Event()
        {
            using(var session = Store.OpenSession())
            using(var kernel = new StandardKernel(new ServerModule()))
            {
                kernel.Bind<IDocumentSession>().ToConstant(session);

                var bus = kernel.Get<IBus>();
                ProjectCreatedEvent @event = null;
                bus.Send<ProjectCreatedEvent>(e => @event = e);
                var command = new CreateProjectBuilder("Test Project").With.Description("A project for testing the Create process") as ICommandCreator<CreateProjectCommand>;
                bus.Send(command.GetCommand());

                Assert.That(@event, Is.Not.Null);
                var eventStore = kernel.Get<IEventStore>();
                var events = eventStore.GetEventsForAggregate(@event.Id);

                Assert.That(events, Has.Count.EqualTo(1));
                var project = new Project();
                project.LoadFromHistory(events);

                Assert.That(project._name, Is.EqualTo("Test Project"));
                Assert.That(project._description, Is.EqualTo("A project for testing the Create process"));
            }
        }
Ejemplo n.º 2
0
 public static IEnumerable<dynamic> Map(IEnumerable<dynamic> events)
 {
     foreach (var project in events.Where(e => e is IEvent<Project>).GroupBy(e => e.AggregateID))
     {
         var proj = new Project(project.Key, (IEnumerable<IEvent>)project.OrderBy(p => p.Version).Select(p => p.EventData));
         yield return new ProjectInfo
         {
             Changes = project.Count(),
             Description = proj._description,
             Name = proj._name,
             ProjectId = proj._id
         };
     }
 }