Example #1
0
        public void GetFilePath_Should_Return_The_Expected_Path()
        {
            _fileInfoMock.GetSize(Arg.Is(expectedFilePath)).Returns(0);
            var path = _filepathProvider.GetFilePath();

            Assert.AreEqual(path, expectedFilePath);
        }
Example #2
0
        public void Log(LogLevel level, string logMessage)
        {
            string path    = _filePathProvider.GetFilePath();
            var    logInfo = GetLogInfo(level);
            string message = GetMessage(logInfo.Item1, logMessage, _dateTimeProvider.UtcNow);

            _fileWriter.Write(path, message);
        }
Example #3
0
        public FileSystemWatcher GetFileWatcher()
        {
            string fullPath  = _filePathProvider.GetFilePath();
            string directory = Path.GetDirectoryName(fullPath);
            string fileName  = Path.GetFileName(fullPath);

            FileSystemWatcher watcher = new FileSystemWatcher(directory);

            watcher.Filter       = fileName;
            watcher.NotifyFilter = NotifyFilters.LastWrite;

            return(watcher);
        }
Example #4
0
 public void CreateScreenshots(IEnumerable <IScreenshotDefinition> screenshotDefinitions)
 {
     foreach (var screenshotDefinition in screenshotDefinitions)
     {
         var filePath = _filePathProvider.GetFilePath(screenshotDefinition.FileName);
         _screenshotProvider.SaveScreenshot(screenshotDefinition.Url, filePath);
     }
 }
Example #5
0
        private void CommitColumn(string symbol, Column column, DateTime start, DateTime end)
        {
            var tmpFile = _filePathProvider.GetTmpFilePath(symbol, column.Name, start);

            if (!tmpFile.FileExists())
            {
                // Todo: LogWarn here No file found to be inserted ! Symbol: {symbol}, Column: {column}, Start: {start:yyyy-MM-dd HH:mm:ss.fff}, Path: {newFile}
                return;
            }

            var entriesToRemove = new List <DateTime>();
            var fileToMerge     = new List <string>();
            var mergedStart     = start;
            var mergedEnd       = end;

            // Gets the files to merge with
            foreach (var entry in column.Search(start, end))
            {
                entriesToRemove.Add(entry.Key);

                var filePath = _filePathProvider.GetFilePath(symbol, column.Name, entry.Key);
                if (!filePath.FileExists())
                {
                    // Todo: LogInfo: The file has been deleted so we remove the entry {entry.Value}, Path: {filePath}
                    continue;
                }

                fileToMerge.Add(filePath);
                mergedStart = Time.Min(mergedStart, entry.Key);
                mergedEnd   = Time.Max(mergedEnd, entry.Value.End);
            }

            // Remove all entries that will be merged
            foreach (var entry in entriesToRemove)
            {
                column.Delete(entry);
            }

            if (fileToMerge.Count > 0)
            {
                // Merge the files
                var slices = Merge(fileToMerge, new[] { tmpFile }, symbol, column, mergedStart);
                foreach (var slice in slices)
                {
                    column.Insert(slice.Start, slice);
                }
            }
            else // No merge to do
            {
                // Move the generated file from the tmp folder to the data folder.
                var newFile = _filePathProvider.GetFilePath(symbol, column.Name, start);
                tmpFile.MoveFileTo(newFile);
                column.Insert(start, CreateSlice(symbol, column, start, end));
            }
        }
Example #6
0
 public void TestInititalize()
 {
     _dateTimeProviderMock = Substitute.For <IDateTimeProvider>();
     _dateTimeProviderMock.UtcNow.Returns(DateTime.UtcNow.ToString());
     _filePathProviderMock = Substitute.For <IFilePathProvider>();
     _filePathProviderMock.GetFilePath().Returns(expectedFilePath);
     _filewriterMock = Substitute.For <IFileWriter>();
     _fileLogger     = new FileLogger(_dateTimeProviderMock, _filePathProviderMock, _filewriterMock);
 }
Example #7
0
        public IScreenshotTestResult Run(IScreenshotDefinition outline)
        {
            var newFilePath = _newFilePathProvider.GetFilePath(outline.FileName);
            var oldFilePath = _oldFilePathProvider.GetFilePath(outline.FileName);

            _screenshotProvider.SaveScreenshot(outline.Url, newFilePath);
            var result = _bitmapComparer.AreSame(oldFilePath, newFilePath);

            return(new ScreenshotTestResult(result));
        }
Example #8
0
 private static FileMetaData Fmd(IFilePathProvider provider, string symbol, string column, DateTime start, DateTime?end = null)
 {
     return(new FileMetaData()
     {
         Symbol = symbol,
         Column = column,
         Start = start.Date,
         End = end ?? start.Date.AddDays(1).Date,
         FilePath = provider.GetFilePath(symbol, column, start)
     });
 }
Example #9
0
        public byte[] GetIv()
        {
            var ivPath = _filePathProvider.GetFilePath(_ivName);

            return(File.ReadAllBytes(ivPath));
        }
Example #10
0
 public FileService(IFilePathProvider filePathProvider)
 {
     _filepPath = filePathProvider.GetFilePath();
 }