public void CancellingFinishingStatus()
        {
            var importStatus = new ImportStatus
            {
                Status = CANCELLING
            };

            Assert.Equal(CANCELLED, importStatus.GetFinishingStateOfAbortProcess());
        }
        public void NoOtherAbortingFinishStates()
        {
            EnumUtil.GetEnumValues <IStatus>().ForEach(status =>
            {
                var importStatus = new ImportStatus
                {
                    Status = status
                };

                if (status != CANCELLING)
                {
                    Assert.Throws <ArgumentOutOfRangeException>(() => importStatus.GetFinishingStateOfAbortProcess());
                }
            });
        }
Esempio n. 3
0
        public async Task CheckComplete_LastBatchFileCompleted_Aborting()
        {
            await AbortingStatuses.ForEachAsync(async abortingStatus =>
            {
                var message = new ImportObservationsMessage
                {
                    ReleaseId    = Guid.NewGuid(),
                    NumBatches   = 2,
                    DataFileName = "my_data_file.csv",
                    TotalRows    = 2,
                    SubjectId    = Guid.NewGuid()
                };

                var importStatusService = new Mock <IImportStatusService>(Strict);
                var fileStorageService  = new Mock <IFileStorageService>();

                var service = BuildFileImportService(
                    importStatusService: importStatusService.Object,
                    fileStorageService: fileStorageService.Object);

                var currentStatus = new ImportStatus
                {
                    Status = abortingStatus
                };

                importStatusService
                .Setup(s => s.GetImportStatus(message.ReleaseId, message.DataFileName))
                .ReturnsAsync(currentStatus);

                importStatusService
                .Setup(s => s.UpdateStatus(
                           message.ReleaseId, message.DataFileName, currentStatus.GetFinishingStateOfAbortProcess(), 100))
                .Returns(Task.CompletedTask);

                var dbContext = StatisticsDbUtils.InMemoryStatisticsDbContext();

                await using (dbContext)
                {
                    await service.CheckComplete(message.ReleaseId, message, dbContext);
                }

                MockUtils.VerifyAllMocks(importStatusService, fileStorageService);
            });
        }