public virtual async Task LoadAllEventsAsyncFindsEventsAfterLargeGaps() { // Arrange var ids = Enumerable.Range(0, 10) .Select(i => ThingyId.New) .ToArray(); foreach (var id in ids) { var command = new ThingyPingCommand(id, PingId.New); await CommandBus.PublishAsync(command).ConfigureAwait(false); } foreach (var id in ids.Skip(1).Take(5)) { await EventPersistence.DeleteEventsAsync(id, CancellationToken.None) .ConfigureAwait(false); } // Act var result = await EventStore .LoadAllEventsAsync(GlobalPosition.Start, 5, CancellationToken.None) .ConfigureAwait(false); // Assert result.DomainEvents.Should().HaveCount(5); }
public ActionResult UpdateEvent() { List <Events> events = EventPersistence.GetAllEvents(); ViewData["events"] = events; return(View(new Events())); }
public ActionResult CommentAdd(Events textin) { string t = textin.Comment.Replace("<", "<"); string t1 = t.Replace(">", ">"); string t2 = t1.Replace("(", "("); string t3 = t2.Replace(")", ")"); string t4 = t3.Replace("&", "&"); string tfinal = t4.Replace("|", "|"); Comment com = new Comment(); com.EventId = textin.EventId; com.Text = tfinal; com.EventName = EventPersistence.getEventD(textin.EventId).EventName; bool result = EventPersistence.AddComment(com); if (result) { ViewBag.message = "Commited"; } else { ViewBag.message = "Couldnt commited"; } return(RedirectToAction("ListEvents", "Event")); }
public ActionResult FindComment() { List <Comment> comments = EventPersistence.GetAllComments(); ViewData["Comments"] = comments; return(View(new Comment())); }
public DefaultEventStore(EventPersistence persistence, DomainEventBus domainEventBus, DomainEventSerializer serializer) { _persistence = persistence; _domainEventBus = domainEventBus; _serializer = serializer; }
/* * Transaction: Update an event in the database * Returns true if the event exists in the database and * it was successfully changed. */ public static bool ChangeEvent(Events changeEvent) { if (EventPersistence.getEvent(changeEvent) == null) { return(false); } return(EventPersistence.UpdateEvent(changeEvent)); }
/* * Transaction: Delete an event from the database * Returns true if the event exists in the database and * it was successfully deleted. */ public static bool DeleteEvent(Events delEvent) { if (EventPersistence.getEvent(delEvent) == null) { return(false); } return(EventPersistence.DeleteEvent(delEvent)); }
public static Comment[] GetAllComments() { List <Comment> comments = EventPersistence.GetAllComments(); if (comments != null) { return(EventPersistence.GetAllComments().ToArray()); } else { return(new Comment[0]); } }
/* * This method takes all events to list to array */ public static Events[] GetAllEvents() { List <Events> events = EventPersistence.GetAllEvents(); if (events != null) { return(EventPersistence.GetAllEvents().ToArray()); } else { return(new Events[0]); } }
public static bool AddNewEvent(Events newEvent) { bool eventChecker = EventPersistence.CheckEventname(newEvent); Events oldEvent = EventPersistence.getEvent(newEvent); if (eventChecker == true) { return(EventPersistence.AddEvent(newEvent)); } return(false); }
public async Task EventStore_get_version_returns_default_for_unknown_id() { var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new XunitLoggerProvider(_testOutputHelper)); var publisher = new SimpleEventPublisher(); var persistence = new EventPersistence(); var eventStore = new EventStore(persistence, publisher, loggerFactory.CreateLogger <EventStore>()); var version = await eventStore.GetVersion(Guid.NewGuid().ToString(), default); Assert.Equal(AggregateRoot.InitialVersion, version); }
public ActionResult FindComment(decimal a) { Comment result = EventPersistence.FindComment(a); List <Comment> list = EventPersistence.GetAllComments(); if (result != null) { TempData["Comment"] = list; return(View("ListEvents")); } return(View("ListEvents")); }
public async Task EventStore_get_events_returns_empty_enumerable_for_unknown_id() { var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new XunitLoggerProvider(_testOutputHelper)); var publisher = new SimpleEventPublisher(); var persistence = new EventPersistence(); var eventStore = new EventStore(persistence, publisher, loggerFactory.CreateLogger <EventStore>()); var retrievedEvents = await eventStore.GetEventStream("invalid_aggragate_id", 0); Assert.False(retrievedEvents.Events.Any()); }
public ActionResult SearchEvent(Events value) { List <Events> events = EventPersistence.GetAllEvents(); if (events != null) { ViewData["events"] = events; return(View(events.Contains(value))); } else { return(View("Home", "Index")); } }
public async Task EventStore_get_version_returns_correct_value() { var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new XunitLoggerProvider(_testOutputHelper)); var aggregateId = Guid.NewGuid().ToString(); var eventStream = new EventStream(aggregateId, 1, new[] { new Event1(), new Event1() }); var persistence = new EventPersistence(new[] { eventStream }); var eventStore = new EventStore(persistence, new SimpleEventPublisher(), loggerFactory.CreateLogger <EventStore>()); var version = await eventStore.GetVersion(aggregateId, default); eventStore.Dispose(); Assert.Equal(2, version); }
public async Task EventStore_get_events_returns_saved_and_higher_state_events_only() { var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new XunitLoggerProvider(_testOutputHelper)); var aggregateId = Guid.NewGuid().ToString(); var eventStream = new EventStream(aggregateId, 1, new[] { new Event1(), new Event1() }); var persistence = new EventPersistence(new[] { eventStream }); var eventStore = new EventStore(persistence, new SimpleEventPublisher(), loggerFactory.CreateLogger <EventStore>()); var retrievedEvents = await eventStore.GetEventStream(aggregateId, default); Assert.True(retrievedEvents.Events.Any()); Assert.Equal(eventStream.Events.Count(), retrievedEvents.Events.Count()); }
public async Task EventStore_save_and_publish_handles_all_events() { var loggerFactory = new LoggerFactory(); loggerFactory.AddProvider(new XunitLoggerProvider(_testOutputHelper)); var publisher = new SimpleEventPublisher(); var persistence = new EventPersistence(); var eventStore = new EventStore(persistence, publisher, loggerFactory.CreateLogger <EventStore>()); var aggregateId = Guid.NewGuid().ToString(); var eventStream = new EventStream(aggregateId, 0, new[] { new Event1(), new Event1() }); await eventStore.SaveAndPublish(eventStream, 0, () => { }, default); eventStore.Dispose(); Assert.Equal(eventStream.Events.Count(), publisher.PublishedEvents.Count); Assert.Equal(eventStream.Events.Count(), persistence.GetPersistedEvents(aggregateId).Events.Count()); }
/* * Handle a request for a listing of events. */ public ActionResult ListEvents() { List <Events> events = EventPersistence.GetAllEvents(); List <Comment> comments = EventPersistence.GetAllComments(); if (events != null && comments != null) { ViewData["eventList"] = events; ViewData["Comments"] = comments; return(View(events)); } if (events != null) { ViewData["eventList"] = events; return(View(events)); } else { return(View("Home", "Index")); } }
public ActionResult UpdateEvent(Events newEvent) { if (newEvent == null) { ViewBag.message = "Error: Invalid Request - please try again"; return(View(new Events())); } if (newEvent.EventId.ToString().Length == 0) { ViewBag.message = "Error: An Id is required"; return(View(newEvent)); } bool result = EventManager.ChangeEvent(newEvent); if (result) { ViewBag.message = "Event Updated"; } else { ViewBag.message = "That event could not be Updated"; } List <Events> events = EventPersistence.GetAllEvents(); if (events == null) { ViewBag.message = "There is not event for listing."; return(View("Home", "Index")); } else { ViewData["eventList"] = events; return(View("ChangeEvent", new Events())); } }
public DefaultEventStore(EventPersistence persistence, DomainEventBus domainEventBus) : this(persistence, domainEventBus, new JsonDomainEventSerializer()) { }