public void Should_return_files_in_correct_order() { fileSystem.GetFilesByPrefix("logs/log.txt").Returns(new FilePath[] { "logs/log3.txt", "logs/log1.txt", "logs/log2.txt" }); RollingStrategyHelper.DiscoverExistingFiles("logs/log.txt", fileSystem, suffixFormatter).Select(e => e.path) .Should().Equal("logs/log1.txt", "logs/log2.txt", "logs/log3.txt"); }
public void AddSuffix_should_correctly_insert_the_suffix(string basePath, string suffix, string expected) { var path = RollingStrategyHelper.AddSuffix(new FilePath(basePath), suffix, false).NormalizedPath; path = path.Remove(0, AppDomain.CurrentDomain.BaseDirectory.Length); path = path.TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); path.Should().Be(expected); }
public void Should_handle_base_paths_with_placeholders() { fileSystem.GetFilesByPrefix(Arg.Any <FilePath>()).Returns(new FilePath[] { "logs/log3file.txt", "logs/log1file.txt", "logs/log", "logs/log513file.txt", "logs/log2file.txt" }); RollingStrategyHelper.DiscoverExistingFiles("logs/log{RollingSuffix}file.txt", fileSystem, suffixFormatter).Select(e => e.path) .Should().Equal("logs/log1file.txt", "logs/log2file.txt", "logs/log3file.txt", "logs/log513file.txt"); RollingStrategyHelper.DiscoverExistingFiles("logs/log{RollingSuffix}file.txt", fileSystem, suffixFormatter).Select(e => e.suffix) .Should().Equal(1, 2, 3, 513); }
public void Should_not_return_paths_where_suffix_could_not_be_parsed() { fileSystem.GetFilesByPrefix("logs/log.txt").Returns(new FilePath[] { "logs/log1.txt", "logs/log~.txt" }); RollingStrategyHelper.DiscoverExistingFiles("logs/log.txt", fileSystem, suffixFormatter).Should().HaveCount(1); }
public void Should_parse_suffix_using_provided_formatter() { RollingStrategyHelper.DiscoverExistingFiles("logs/log.txt", fileSystem, suffixFormatter) .Single().suffix.Should().Be(1); }