public PrintResponseCommand(
     ILogger <PrintResponseCommand> logger,
     IBatchService batchService,
     IExternalBlobFileTransferClient externalFileTransferClient,
     IInternalBlobFileTransferClient internalFileTransferClient,
     IOptions <PrintResponseOptions> printReponseOptions)
     : base(externalFileTransferClient, internalFileTransferClient)
 {
     _logger       = logger;
     _batchService = batchService;
     _options      = printReponseOptions?.Value;
 }
예제 #2
0
        public void Arrange()
        {
            _mockLogger       = new Mock <ILogger <Domain.Print.PrintResponseCommand> >();
            _mockBatchService = new Mock <IBatchService>();
            _mockExternalFileTransferClient = new Mock <IExternalBlobFileTransferClient>();
            _mockInternalFileTransferClient = new Mock <IInternalBlobFileTransferClient>();
            _mockOptions      = new Mock <IOptions <PrintResponseOptions> >();
            _mockMessageQueue = new Mock <ICollector <CertificatePrintStatusUpdateMessage> >();

            _options = new PrintResponseOptions {
                Directory        = "MockPrintResponseDirectory",
                ArchiveDirectory = "MockArchivePrintResponseDirectory"
            };

            _mockOptions
            .Setup(m => m.Value)
            .Returns(_options);

            _downloadedFiles = new List <string>();
            var generator = new RandomGenerator();

            for (int i = 0; i < 10; i++)
            {
                var filename = $"PrintResponse-0120-{generator.Next(111111, 999999)}.json";
                _downloadedFiles.Add(filename);

                _mockExternalFileTransferClient
                .Setup(m => m.DownloadFile($"{_options.Directory}/{filename}"))
                .ReturnsAsync(JsonConvert.SerializeObject(new PrintReceipt {
                    Batch = new BatchData {
                        BatchNumber           = _batchNumber,
                        BatchDate             = DateTime.Now.AddDays(-1),
                        ProcessedDate         = DateTime.Now,
                        PostalContactCount    = 2,
                        TotalCertificateCount = 6
                    }
                }));
            }
            ;

            _mockExternalFileTransferClient
            .Setup(m => m.GetFileNames(It.IsAny <string>(), It.IsAny <string>(), false))
            .ReturnsAsync(_downloadedFiles);

            _mockBatchService
            .Setup(m => m.Get(_batchNumber))
            .ReturnsAsync(new Batch {
                BatchNumber = _batchNumber
            });

            _mockBatchService
            .Setup(m => m.Update(It.IsAny <Batch>()))
            .ReturnsAsync(new List <CertificatePrintStatusUpdateMessage>());

            _sut = new Domain.Print.PrintResponseCommand(
                _mockLogger.Object,
                _mockBatchService.Object,
                _mockExternalFileTransferClient.Object,
                _mockInternalFileTransferClient.Object,
                _mockOptions.Object
                );
        }