public void Should_Store_Events_When_Publish_Event() { var eventStore = new EventStoreInMemory(); var eventPublisher = new EventPublisher(eventStore, new List <IEventHandler>()); eventPublisher.Publish(new OrderStarted(new OrderId("1"), 1), 1); Assert.Contains(new OrderStarted(new OrderId("1"), 1), eventStore.GetAll(new OrderId("1"))); }
Should_Return_All_Events_When_Get_All_Events_Of_Aggregate_Instance_After_Store_Events_Of_An_Aggregate_Instance() { var eventStore = new EventStoreInMemory(); eventStore.Add(new OrderStarted(new OrderId("1"), 5), 1); eventStore.Add(new MarchandiseReceived(new OrderId("1"), 5), 2); var events = eventStore.GetAll(new OrderId("1")); Assert.Equal(2, events.Count); }
Should_Return_only_events_of_aggregate_instance_when_get_all_events_of_aggregate_instance_after_store_events_of_several_aggregate_instances() { var eventStore = new EventStoreInMemory(); eventStore.Add(new OrderStarted(new OrderId("1"), 5), 1); eventStore.Add(new MarchandiseReceived(new OrderId("1"), 5), 2); eventStore.Add(new OrderStarted(new OrderId("2"), 5), 1); var events = eventStore.GetAll(new OrderId("1")); Assert.Equal(2, events.Count); }