//readonly SendNotificationCommandHGandler sendNotificationCommand;

        public DocumentController(
            CreateDocumentCommandHandler createCommandHandler,
            SearchDocumentsQuery searchDocumentsQuery,
            SearchCountQuery searchCountQuery,
            DownloadFileQuery downloadFileQuery,
            GetOneDocumentQuery getOneQuery,
            GetAllDocumentTypesQuery getDTsQuery,
            GetAllEntitiesQuery getEsQuery,
            GetAllDocumentTypesByUserQuery getDTByUserQuery,
            DocumentsWithoutFilePagedQuery withoutFileQuery,
            UpdateFileToDocumentCommandHandler updateFileCommandHandler,
            DeleteDocumentCommandHandler deleteDocumentCommand,
            SendDocumentNotificationCommandHandler sendDocmentNotificationCommandHandler
            //SendNotificationCommandHGandler sendNotificationCommand) {
            )
        {
            _createCommandHandler         = createCommandHandler;
            this.searchDocumentsQuery     = searchDocumentsQuery;
            this.searchCountQuery         = searchCountQuery;
            this.downloadFileQuery        = downloadFileQuery;
            this.getOneQuery              = getOneQuery;
            this.getDTsQuery              = getDTsQuery;
            this.getEsQuery               = getEsQuery;
            this.withoutFileQuery         = withoutFileQuery;
            this.updateFileCommandHandler = updateFileCommandHandler;
            this.deleteDocumentCommand    = deleteDocumentCommand;
            this.sendDocumentNotificationCommandHandler = sendDocmentNotificationCommandHandler;
            this.getDTByUserQuery = getDTByUserQuery;
            //this.sendNotificationCommand = sendNotificationCommand;
        }
        public async Task CreateDocumentCommand_CustomerDataCreateOnFile()
        {
            //Arange
            var ocrRServiceMoq   = new Mock <IOCRService>();
            var writeIRepository = new Mock <IWriteIRepository> ();
            var command          = new CreateDocumentCommand()
            {
                FileName = "test", UserId = 1
            };
            var config  = new MapperConfiguration(cfg => cfg.AddProfile <OCRProfile>());
            var handler = new CreateDocumentCommandHandler(ocrRServiceMoq.Object, writeIRepository.Object, config.CreateMapper());

            //Act
            DocumentDTO x = await handler.Handle(command, new System.Threading.CancellationToken());

            //Asert
            ocrRServiceMoq.Verify(x => x.GetText(It.IsAny <byte[]>()), Times.Once);
        }
Example #3
0
        public async Task Handler_GivenEmptyFileParameters_ReturnsTrue()
        {
            var filename          = "example.pdf";
            var bytes             = new byte[0];
            var cancellationToken = new CancellationToken();

            var dateCreated      = new DateTime(2000, 12, 31, 01, 02, 03);
            var dateTimeProvider = new Mock <IDateTimeProvider>();

            dateTimeProvider.Setup(x => x.UtcNow).Returns(dateCreated);

            var repository = new Mock <IDocumentRepository>();
            var factory    = new DocumentFactory(dateTimeProvider.Object);

            var request = new CreateDocumentCommand(filename, bytes.Length);
            var handler = new CreateDocumentCommandHandler(repository.Object, factory);

            var result = await handler.Handle(request, cancellationToken);

            result.IsSuccessful.ShouldBeFalse();
        }