/// <summary> /// Plays the event. /// </summary> /// <param name="domainEvent">The domain event.</param> private void PlayEvent(FileLineProcessingFailedEvent domainEvent) { FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber); fileLine.TransactionId = domainEvent.TransactionId; fileLine.ProcessingResult = ProcessingResult.Failed; }
public void FileProcessorDomainEventHandler_FileLineProcessingFailedEvent_EventIsHandled() { FileLineProcessingFailedEvent domainEvent = TestData.FileLineProcessingFailedEvent; 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); }); }
public void FileLineProcessingFailedEvent_CanBeCreated_IsCreated() { FileLineProcessingFailedEvent fileLineProcessingFailedEvent = new FileLineProcessingFailedEvent(TestData.FileId, TestData.EstateId, TestData.LineNumber, TestData.TransactionId, TestData.ResponseCode, TestData.ResponseMessage); fileLineProcessingFailedEvent.FileId.ShouldBe(TestData.FileId); fileLineProcessingFailedEvent.LineNumber.ShouldBe(TestData.LineNumber); fileLineProcessingFailedEvent.TransactionId.ShouldBe(TestData.TransactionId); fileLineProcessingFailedEvent.EstateId.ShouldBe(TestData.EstateId); fileLineProcessingFailedEvent.ResponseCode.ShouldBe(TestData.ResponseCode); fileLineProcessingFailedEvent.ResponseMessage.ShouldBe(TestData.ResponseMessage); }
/// <summary> /// Records the file line as failed. /// </summary> /// <param name="lineNumber">The line number.</param> /// <param name="transactionId">The transaction identifier.</param> /// <param name="responseCode">The response code.</param> /// <param name="responseMessage">The response message.</param> /// <exception cref="InvalidOperationException">File has no lines to mark as failed</exception> /// <exception cref="NotFoundException">File line with number {lineNumber} not found to mark as failed</exception> public void RecordFileLineAsFailed(Int32 lineNumber, Guid transactionId, String responseCode, String responseMessage) { if (this.FileLines.Any() == false) { throw new InvalidOperationException("File has no lines to mark as failed"); } if (this.FileLines.SingleOrDefault(l => l.LineNumber == lineNumber) == null) { throw new NotFoundException($"File line with number {lineNumber} not found to mark as failed"); } FileLineProcessingFailedEvent fileLineProcessingFailedEvent = new FileLineProcessingFailedEvent(this.AggregateId, this.EstateId, lineNumber, transactionId, responseCode, responseMessage); this.ApplyAndAppend(fileLineProcessingFailedEvent); 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(FileLineProcessingFailedEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken); }