public void ConsoleService_ProcessFiles_NullParamaterThrowsArgumentNullException()
        {
            // Arrange
            var annualMapperMock = new Mock <IFileConversionOrchestrator>();

            var consoleService = new ConsoleService(annualMapperMock.Object, null);
            FileConversionContext fileConversionContext = null;

            // Act & Assert
            Func <Task> action = async() => await consoleService.ProcessFilesAsync(fileConversionContext, new CancellationToken());

            action.Should().Throw <ArgumentNullException>();
        }
        public void ConsoleService_ProcessFiles_MissingSourceFileThrowsArgumentException()
        {
            // Arrange
            var annualMapperMock = new Mock <IFileConversionOrchestrator>();
            var fileServiceMock  = new Mock <IFileService>();

            var consoleService = new ConsoleService(annualMapperMock.Object, fileServiceMock.Object);
            FileConversionContext fileConversionContext = new FileConversionContext
            {
                SourceFile   = sourcefileName,
                TargetFolder = targetFilePath,
            };

            // Act
            Func <Task> action = async() => await consoleService.ProcessFilesAsync(fileConversionContext, new CancellationToken());

            action.Should().Throw <ArgumentException>();

            // Assert
            fileServiceMock.Verify(v => v.ExistsAsync(sourcefileName, null, It.IsAny <CancellationToken>()), Times.Once);
        }
        public async Task ConsoleService_ProcessFiles_ValidFilesCallMapFileAsync()
        {
            // Arrange
            var annualMapperMock = new Mock <IFileConversionOrchestrator>();
            var fileServiceMock  = new Mock <IFileService>();

            fileServiceMock.Setup(c => c.ExistsAsync(sourcefileName, null, It.IsAny <CancellationToken>())).ReturnsAsync(true);

            var consoleService = new ConsoleService(annualMapperMock.Object, fileServiceMock.Object);
            FileConversionContext fileConversionContext = new FileConversionContext
            {
                SourceFile   = sourcefileName,
                TargetFolder = targetFilePath,
            };

            // Act
            await consoleService.ProcessFilesAsync(fileConversionContext, new CancellationToken());

            // Assert
            fileServiceMock.Verify(v => v.ExistsAsync(sourcefileName, null, It.IsAny <CancellationToken>()), Times.Once);
            annualMapperMock.Verify(v => v.MapFileAsync(sourcefileName, string.Empty, targetFilePath, It.IsAny <CancellationToken>()), Times.Once);
        }
        public void ConsoleService_ProcessFiles_InvalidFileConversionContextThrowsArgumentException(
            string sourceFile,
            string sourceFolder,
            string targetFolder)
        {
            // Arrange
            var annualMapperMock = new Mock <IFileConversionOrchestrator>();
            var fileServiceMock  = new Mock <IFileService>();

            var consoleService = new ConsoleService(annualMapperMock.Object, fileServiceMock.Object);
            FileConversionContext fileConversionContext = new FileConversionContext
            {
                SourceFile   = sourceFile,
                SourceFolder = sourceFolder,
                TargetFolder = targetFolder,
            };

            // Act & Assert
            Func <Task> action = async() => await consoleService.ProcessFilesAsync(fileConversionContext, new CancellationToken());

            action.Should().Throw <ArgumentException>();
        }
Beispiel #5
0
 public FileConversionRepository(ILogger <FileConversionRepository <TEntity> > logger,
                                 FileConversionContext context) : base(logger, context)
 {
 }