Ejemplo n.º 1
0
        public async Task FileProcessingManager_GetFile_FileReturnedWithUserEmailAddress()
        {
            List <FileProfile> fileProfiles = new List <FileProfile>();
            var context = await this.GetContext(Guid.NewGuid().ToString("N"));

            context.EstateSecurityUsers.Add(new EstateSecurityUser()
            {
                EstateId       = TestData.EstateId,
                SecurityUserId = TestData.UserId,
                EmailAddress   = TestData.UserEmailAddress
            });
            context.SaveChanges();
            var contextFactory = this.CreateMockContextFactory();

            contextFactory.Setup(c => c.GetContext(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(context);
            IModelFactory modelFactory = new ModelFactory();

            Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> > fileAggregateRepository =
                new Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> >();

            fileAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.GetFileAggregateWithLines);
            FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory, fileAggregateRepository.Object);

            var fileDetails = await manager.GetFile(TestData.FileId, TestData.EstateId, CancellationToken.None);

            this.VerifyFile(TestData.GetFileAggregateWithLines(), fileDetails);
            fileDetails.UserEmailAddress.ShouldBe(TestData.UserEmailAddress);
        }
Ejemplo n.º 2
0
        public async Task FileProcessingManager_GetFileProfile_FIleProfileReturned()
        {
            var fileProfiles   = TestData.FileProfiles;
            var contextFactory = this.CreateMockContextFactory();
            Mock <IModelFactory> modelFactory = new Mock <IModelFactory>();
            Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> > fileAggregateRepository =
                new Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> >();
            FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory.Object, fileAggregateRepository.Object);

            var fileProfile = await manager.GetFileProfile(TestData.SafaricomFileProfileId, CancellationToken.None);

            fileProfile.ShouldNotBeNull();
            fileProfile.FileProfileId.ShouldBe(TestData.SafaricomFileProfileId);
        }
Ejemplo n.º 3
0
        public async Task FileProcessingManager_GetAllFileProfiles_AllFileProfilesReturned()
        {
            var fileProfiles   = TestData.FileProfiles;
            var contextFactory = this.CreateMockContextFactory();
            Mock <IModelFactory> modelFactory = new Mock <IModelFactory>();
            Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> > fileAggregateRepository =
                new Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> >();
            FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory.Object, fileAggregateRepository.Object);

            var allFileProfiles = await manager.GetAllFileProfiles(CancellationToken.None);

            allFileProfiles.ShouldNotBeNull();
            allFileProfiles.ShouldNotBeEmpty();
        }
Ejemplo n.º 4
0
        public async Task FileProcessingManager_GetFile_FileNotFound_ErrorThrown()
        {
            var fileProfiles = TestData.FileProfiles;
            var context      = await this.GetContext(Guid.NewGuid().ToString("N"));

            var contextFactory = this.CreateMockContextFactory();

            contextFactory.Setup(c => c.GetContext(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(context);
            IModelFactory modelFactory = new ModelFactory();

            Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> > fileAggregateRepository =
                new Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> >();

            fileAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(TestData.GetEmptyFileAggregate);
            FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory, fileAggregateRepository.Object);

            Should.Throw <NotFoundException>(async() =>
            {
                await manager.GetFile(TestData.FileId, TestData.EstateId, CancellationToken.None);
            });
        }
Ejemplo n.º 5
0
        public async Task FileProcessingManager_GetFileImportLogs_WithMerchantId_ImportLogsReturned()
        {
            var fileProfiles = TestData.FileProfiles;
            var context      = await this.GetContext(Guid.NewGuid().ToString("N"));

            var contextFactory = this.CreateMockContextFactory();

            contextFactory.Setup(c => c.GetContext(It.IsAny <Guid>(), It.IsAny <CancellationToken>())).ReturnsAsync(context);
            IModelFactory modelFactory = new ModelFactory();

            context.FileImportLogs.AddRange(TestData.FileImportLogs);
            context.FileImportLogFiles.AddRange(TestData.FileImportLog1Files);
            context.FileImportLogFiles.AddRange(TestData.FileImportLog2Files);
            context.SaveChanges();

            Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> > fileAggregateRepository =
                new Mock <IAggregateRepository <FileAggregate, DomainEventRecord.DomainEvent> >();
            FileProcessorManager manager = new FileProcessorManager(fileProfiles, contextFactory.Object, modelFactory, fileAggregateRepository.Object);

            var importLogs = await manager.GetFileImportLogs(TestData.EstateId, TestData.ImportLogStartDate, TestData.ImportLogEndDate, TestData.MerchantId, CancellationToken.None);

            this.VerifyImportLogs(TestData.FileImportLogs, importLogs, TestData.MerchantId);
        }