Exemplo n.º 1
0
        public void Setup()
        {
            _command = new UploadAppealFileCommand
            {
                ApplicationId = _applicationId,
                AppealFile    = new FileUpload {
                    FileName = "test.pdf", Data = new byte[] { 0x25, 0x50, 0x44, 0x46 }, ContentType = "application/pdf"
                },
                UserId   = "userId",
                UserName = "******"
            };

            _appealUploadRepository = new Mock <IAppealFileRepository>();
            _appealUploadRepository.Setup(x => x.Get(_command.ApplicationId, _command.AppealFile.FileName)).ReturnsAsync(default(AppealFile));
            _appealUploadRepository.Setup(x => x.Add(It.IsAny <AppealFile>()));
            _appealUploadRepository.Setup(x => x.Update(It.IsAny <AppealFile>()));


            _auditService = new Mock <IAuditService>();
            _auditService.Setup(x => x.StartTracking(UserAction.UploadAppealFile, _command.UserId, _command.UserName));
            _auditService.Setup(x => x.AuditInsert(It.IsAny <AppealFile>()));
            _auditService.Setup(x => x.AuditUpdate(It.IsAny <AppealFile>()));

            _handler = new UploadAppealFileCommandHandler(_appealUploadRepository.Object, _auditService.Object);
        }
Exemplo n.º 2
0
        public void Setup()
        {
            _command = new UploadAppealFileCommand
            {
                ApplicationId = _applicationId,
                File          = GenerateTestFileUpload(),
                UserId        = "userId",
                UserName      = "******"
            };

            _appealUploadRepository = new Mock <IAppealUploadRepository>();
            _appealUploadRepository.Setup(x => x.Add(It.IsAny <AppealUpload>()));

            _appealFileStorage = new Mock <IAppealsFileStorage>();
            _appealFileStorage.Setup(x => x.Add(_applicationId, It.IsAny <FileUpload>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => _fileStorageFileId);

            _auditService = new Mock <IAuditService>();
            _auditService.Setup(x => x.StartTracking(UserAction.UploadAppealFile, _command.UserId, _command.UserName));
            _auditService.Setup(x => x.AuditInsert(It.IsAny <AppealUpload>()));

            _handler = new UploadAppealFileCommandHandler(_appealUploadRepository.Object, _appealFileStorage.Object, _auditService.Object);
        }