/// <summary> /// Plays the event. /// </summary> /// <param name="domainEvent">The domain event.</param> private void PlayEvent(FileLineProcessingIgnoredEvent domainEvent) { // find the line FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber); fileLine.ProcessingResult = ProcessingResult.Ignored; }
public void FileLineProcessingIgnoredEvent_CanBeCreated_IsCreated() { FileLineProcessingIgnoredEvent fileLineProcessingIgnoredEvent = new FileLineProcessingIgnoredEvent(TestData.FileId, TestData.EstateId, TestData.LineNumber); fileLineProcessingIgnoredEvent.FileId.ShouldBe(TestData.FileId); fileLineProcessingIgnoredEvent.LineNumber.ShouldBe(TestData.LineNumber); fileLineProcessingIgnoredEvent.EstateId.ShouldBe(TestData.EstateId); }
public void FileProcessorDomainEventHandler_FileLineProcessingIgnoredEvent_EventIsHandled() { FileLineProcessingIgnoredEvent domainEvent = TestData.FileLineProcessingIgnoredEvent; Mock <IEstateReportingRepository> estateReportingRepository = new Mock <IEstateReportingRepository>(); FileProcessorDomainEventHandler eventHandler = new FileProcessorDomainEventHandler(estateReportingRepository.Object); Logger.Initialise(NullLogger.Instance); Should.NotThrow(async() => { await eventHandler.Handle(domainEvent, CancellationToken.None); }); }
/// <summary> /// Records the file line as ignored. /// </summary> /// <param name="lineNumber">The line number.</param> /// <exception cref="InvalidOperationException">File has no lines to mark as successful</exception> /// <exception cref="NotFoundException">File line with number {lineNumber} not found to mark as successful</exception> public void RecordFileLineAsIgnored(Int32 lineNumber) { if (this.FileLines.Any() == false) { throw new InvalidOperationException("File has no lines to mark as ignored"); } if (this.FileLines.SingleOrDefault(l => l.LineNumber == lineNumber) == null) { throw new NotFoundException($"File line with number {lineNumber} not found to mark as ignored"); } FileLineProcessingIgnoredEvent fileLineProcessingIgnoredEvent = new FileLineProcessingIgnoredEvent(this.AggregateId, this.EstateId, lineNumber); this.ApplyAndAppend(fileLineProcessingIgnoredEvent); this.CompletedChecks(); }
/// <summary> /// Handles the specific domain event. /// </summary> /// <param name="domainEvent">The domain event.</param> /// <param name="cancellationToken">The cancellation token.</param> private async Task HandleSpecificDomainEvent(FileLineProcessingIgnoredEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken); }