public void EventConstants_EventHierarchies(Tuple <EventSourceType, Event> evntt) { //Arrange var evnt = evntt.Item2; //Act var result = EventConstants.GetNextEvents(evnt.SourceType); //Assert Assert.That(result, Is.Not.Null, $"The hierarchy should never return null {evnt.SourceType}"); }
/// <summary> /// For the check events `ShouldContinue=true` indicates that the event should move onto the next task(s) /// and `ShouldContinue=false` indicates that we loop on the same event type. /// </summary> /// <param name="result"></param> /// <param name="previousEvent"></param> /// <returns></returns> public async Task CreateNextEvents(EventResult result, Event previousEvent) { // result.Succeeded is false only when the event errors and in that case we don't mark it errored and don't continue. if (!result.Succeeded) { await this.logger.LogVerboseAsync("Event failed. No Next Events."); return; } // Grab next types if result should continue, else repeat event type var nextTypes = result.ShouldContinue ? EventConstants.GetNextEvents(previousEvent.SourceType) : new[] { previousEvent.SourceType }; // Convert previous source id to array var nextSourceIds = previousEvent.SourceId.HasValue ? new[] { previousEvent.SourceId.Value } : null; await this.logger.LogVerboseAsync($"Next event with types {nextTypes.Join("{0},{1}")}"); // Create next events await this.eventSourceService.CreateNextEvents(nextSourceIds, nextTypes, EventSourceService.GetIncreasingDelay(previousEvent), previousEvent.Id, previousEvent.HourId); }
public async Task CreateNextEvents(EventResult result, Event previousEvent) { if (!result.Succeeded) { await this.logger.LogVerboseAsync("Event failed. No Next Events."); return; } // if the result is then we never create any next events if (!result.ShouldContinue) { return; } result.Types = (result.Types != null && result.Types.Any()) ? result.Types : EventConstants.GetNextEvents(previousEvent.SourceType).ToList(); await this.logger.LogVerboseAsync($"Next event source ids: {result?.SourceIds?.Join("{0},{1}")} and with types {result?.Types?.Join("{0},{1}")}; Previous event: {previousEvent.Id}"); await this.eventSourceService.CreateNextEvents(result.SourceIds, result.Types, result.Delay, previousEvent.Id, previousEvent.HourId); }