예제 #1
0
        /// <summary>
        /// Plays the event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        private void PlayEvent(FileLineProcessingSuccessfulEvent domainEvent)
        {
            // find the line
            FileLine fileLine = this.FileLines.Single(f => f.LineNumber == domainEvent.LineNumber);

            fileLine.TransactionId    = domainEvent.TransactionId;
            fileLine.ProcessingResult = ProcessingResult.Successful;
        }
        public void FileLineProcessingSuccessfulEvent_CanBeCreated_IsCreated()
        {
            FileLineProcessingSuccessfulEvent fileLineProcessingSuccessfulEvent =
                new FileLineProcessingSuccessfulEvent(TestData.FileId, TestData.EstateId, TestData.LineNumber, TestData.TransactionId);

            fileLineProcessingSuccessfulEvent.FileId.ShouldBe(TestData.FileId);
            fileLineProcessingSuccessfulEvent.LineNumber.ShouldBe(TestData.LineNumber);
            fileLineProcessingSuccessfulEvent.TransactionId.ShouldBe(TestData.TransactionId);
            fileLineProcessingSuccessfulEvent.EstateId.ShouldBe(TestData.EstateId);
        }
        public void FileProcessorDomainEventHandler_FileLineProcessingSuccessfulEvent_EventIsHandled()
        {
            FileLineProcessingSuccessfulEvent domainEvent = TestData.FileLineProcessingSuccessfulEvent;

            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); });
        }
예제 #4
0
        /// <summary>
        /// Records the file line as successful.
        /// </summary>
        /// <param name="lineNumber">The line number.</param>
        /// <param name="transactionId">The transaction identifier.</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 RecordFileLineAsSuccessful(Int32 lineNumber, Guid transactionId)
        {
            if (this.FileLines.Any() == false)
            {
                throw new InvalidOperationException("File has no lines to mark as successful");
            }

            if (this.FileLines.SingleOrDefault(l => l.LineNumber == lineNumber) == null)
            {
                throw new NotFoundException($"File line with number {lineNumber} not found to mark as successful");
            }

            FileLineProcessingSuccessfulEvent fileLineProcessingSuccessfulEvent =
                new FileLineProcessingSuccessfulEvent(this.AggregateId, this.EstateId, lineNumber, transactionId);

            this.ApplyAndAppend(fileLineProcessingSuccessfulEvent);

            this.CompletedChecks();
        }
예제 #5
0
 /// <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(FileLineProcessingSuccessfulEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.EstateReportingRepository.UpdateFileLine(domainEvent, cancellationToken);
 }