//private static Int32 TransactionNumber = 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(FileLineAddedEvent domainEvent,
                                                     CancellationToken cancellationToken)
        {
            ProcessTransactionForFileLineRequest request = new ProcessTransactionForFileLineRequest(domainEvent.FileId, domainEvent.LineNumber, domainEvent.FileLine);

            await this.Mediator.Send(request, cancellationToken);
        }
Esempio n. 2
0
 /// <summary>
 /// Plays the event.
 /// </summary>
 /// <param name="domainEvent">The domain event.</param>
 private void PlayEvent(FileLineAddedEvent domainEvent)
 {
     this.FileLines.Add(new FileLine
     {
         LineData   = domainEvent.FileLine,
         LineNumber = domainEvent.LineNumber
     });
 }
        public void FileLineAddedEvent_CanBeCreated_IsCreated()
        {
            FileLineAddedEvent fileLineAddedEvent = new FileLineAddedEvent(TestData.FileId, TestData.EstateId, TestData.LineNumber, TestData.FileLine);

            fileLineAddedEvent.FileLine.ShouldBe(TestData.FileLine);
            fileLineAddedEvent.EstateId.ShouldBe(TestData.EstateId);
            fileLineAddedEvent.FileId.ShouldBe(TestData.FileId);
            fileLineAddedEvent.LineNumber.ShouldBe(TestData.LineNumber);
        }
        public void FileDomainEventHandler_FileLineAddedEvent_EventIsHandled()
        {
            Mock <IMediator>       mediator           = new Mock <IMediator>();
            FileDomainEventHandler eventHandler       = new FileDomainEventHandler(mediator.Object);
            FileLineAddedEvent     fileLineAddedEvent = TestData.FileLineAddedEvent;

            Should.NotThrow(async() =>
            {
                await eventHandler.Handle(fileLineAddedEvent, CancellationToken.None);
            });
        }
        public void FileProcessorDomainEventHandler_FileLineAddedEvent_EventIsHandled()
        {
            FileLineAddedEvent domainEvent = TestData.FileLineAddedEvent;

            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); });
        }
Esempio n. 6
0
        /// <summary>
        /// Adds the file line.
        /// </summary>
        /// <param name="fileLine">The file line.</param>
        /// <exception cref="InvalidOperationException">File Id {this.AggregateId} has not been uploaded yet</exception>
        public void AddFileLine(String fileLine)
        {
            if (this.IsCreated == false)
            {
                throw new InvalidOperationException($"File Id {this.AggregateId} has not been uploaded yet");
            }

            Int32 lineNumber = this.FileLines.Count + 1;

            FileLineAddedEvent fileLineAddedEvent = new FileLineAddedEvent(this.AggregateId, this.EstateId, lineNumber, fileLine);

            this.ApplyAndAppend(fileLineAddedEvent);
        }
        public static void LoadTypes()
        {
            FileAddedToImportLogEvent fileAddedToImportLogEvent =
                new FileAddedToImportLogEvent(Guid.Empty,
                                              Guid.Empty,
                                              Guid.Empty,
                                              Guid.Empty,
                                              Guid.Empty,
                                              Guid.Empty,
                                              String.Empty,
                                              String.Empty,
                                              new DateTime());

            FileLineAddedEvent fileLineAddedEvent = new FileLineAddedEvent(Guid.Empty, Guid.Empty, 0, String.Empty);

            TypeProvider.LoadDomainEventsTypeDynamically();
        }
Esempio n. 8
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(FileLineAddedEvent domainEvent,
                                              CancellationToken cancellationToken)
 {
     await this.EstateReportingRepository.AddFileLineToFile(domainEvent, cancellationToken);
 }