예제 #1
0
        public void TestGetAccountNode()
        {
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            IXmlAccountConfig indexSpecification = new XmlAccountConfig(_accountConfigPath, _fileHandler);

            Assert.Equal("99802", indexSpecification.GetAccountNode("99802").FirstChild.InnerText);
        }
        public void TestCheckModel()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            //Act
            _fileHandler.CheckModel(_exportModel);
        }
        public void TestBackupFileForFileNotFound()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            //Act
            Action a = () => _fileHandler.BackupFile(_fileHandler.FileSys.FileInfo.FromFileName(@"c:\NotExisting.txt"), _exportModel.BackupDirectory);

            Assert.Throws <FileNotFoundException>(a);
        }
예제 #4
0
        public void TestGetRootNode()
        {
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            IXmlIdxIndexSpecification indexSpecification = new XmlIdxIndexSpecification(_idxSpecification, _fileHandler);

            indexSpecification.GetIndexListNode();

            Assert.Equal("Index", indexSpecification.GetIndexListNode().Name);
        }
        public void TestZipEmailFileToForFileAlreadyExists()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            //Act
            _fileHandler.ExportEmlFile(_fileHandler.FileSys.FileInfo.FromFileName(_testZipFile), _exportModel.ImportDirectory);

            //Assert
            string zipFile = Path.Combine(_exportModel.ImportDirectory, Path.GetFileNameWithoutExtension(_testEmlFile) + ".zip");

            Assert.True(_fileHandler.FileSys.File.Exists(zipFile));
        }
        public void TestCreateReadyFileForIdxNotExisting()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            //Act
            _fileHandler.CreateReadyFile(_fileHandler.FileSys.FileInfo.FromFileName(_testZipFile));

            //Assert
            string readyFile = Path.Combine(_exportModel.ErrorDirectory, Path.ChangeExtension(Path.GetFileName(_testZipFile), "rdy"));

            Assert.False(_fileHandler.FileSys.File.Exists(readyFile));
        }
        public void TestGetImportFiles()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            //Act
            IFileInfo[] files = _fileHandler.GetImportFiles(_exportModel.ErrorDirectory);


            //Assert
            Assert.Contains(_fileHandler.FileSys.FileInfo.FromFileName(_testZipFile), files);
            Assert.Contains(_fileHandler.FileSys.FileInfo.FromFileName(_testEmlFile), files);
            Assert.DoesNotContain(_fileHandler.FileSys.FileInfo.FromFileName(@"c:\NotfallImporter\Error\TextFile.txt"), files);
        }
        public void TestBackupFile()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            //Act
            _fileHandler.BackupFile(_fileHandler.FileSys.FileInfo.FromFileName(_testZipFile), _exportModel.BackupDirectory);

            //Assert
            DateTime currentDate = DateTime.Today;
            string   backupFile  = Path.Combine(@"c:\NotfallImporter\Backup", "Backup" + currentDate.ToString("dd_MM_yy"), Path.GetFileName(_testZipFile));

            Assert.True(_fileHandler.FileSys.File.Exists(backupFile));
            Assert.False(_fileHandler.FileSys.File.Exists(_testZipFile));
        }
        public void TestCheckModelNotExisting()
        {
            //Arrange
            _fileHandler.FileSys = TestFileSystem.CreateFileSystem();

            ExportModel model = new ExportModel()
            {
                ErrorDirectory        = @"c:\NotfallImporter\NotExisting",
                BackupDirectory       = @"c:\NotfallImporter\NotExisting",
                ImportDirectory       = @"c:\NotfallImporter\NotExisting",
                AccountConfig         = @"c:\NotfallImporter\NotExisting",
                IdxIndexSpecification = @"c:\NotfallImporter\NotExisting"
            };


            //Act
            Action a = () => _fileHandler.CheckModel(new ExportModel()
            {
                BackupDirectory = @"c:\NotExisting"
            });

            Assert.Throws <DirectoryNotFoundException>(a);
        }
 public FileHandlerTests()
 {
     _fileHandler         = new FileHandler();
     _fileHandler.FileSys = TestFileSystem.CreateFileSystem();
 }