public void returns_all_existing_files_with_correct_pattern()
        {
            File.Create(Path.Combine(PathName, "foo")).Close();
            File.Create(Path.Combine(PathName, "bla")).Close();

            File.Create(Path.Combine(PathName, "chunk-000001.000000")).Close();
            File.Create(Path.Combine(PathName, "chunk-000002.000000")).Close();
            File.Create(Path.Combine(PathName, "chunk-000003.000000")).Close();

            File.Create(Path.Combine(PathName, "chunk-000005.000000")).Close();
            File.Create(Path.Combine(PathName, "chunk-000005.000007")).Close();
            File.Create(Path.Combine(PathName, "chunk-000005.000002")).Close();
            File.Create(Path.Combine(PathName, "chunk-000005.000005")).Close();

            var strategy = new VersionedPatternFileNamingStrategy(PathName, "chunk");
            var versions = strategy.GetAllPresentFiles();
            Array.Sort(versions, StringComparer.CurrentCultureIgnoreCase);
            Assert.AreEqual(7, versions.Length);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000001.000000"), versions[0]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000002.000000"), versions[1]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000003.000000"), versions[2]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000000"), versions[3]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000002"), versions[4]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000005"), versions[5]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000007"), versions[6]);
        }
        public void returns_all_existing_versions_of_the_same_chunk_in_descending_order_of_versions()
        {
            File.Create(Path.Combine(PathName, "foo")).Close();
            File.Create(Path.Combine(PathName, "bla")).Close();

            File.Create(Path.Combine(PathName, "chunk-000001.000000")).Close();
            File.Create(Path.Combine(PathName, "chunk-000002.000000")).Close();
            File.Create(Path.Combine(PathName, "chunk-000003.000000")).Close();

            File.Create(Path.Combine(PathName, "chunk-000005.000000")).Close();
            File.Create(Path.Combine(PathName, "chunk-000005.000007")).Close();
            File.Create(Path.Combine(PathName, "chunk-000005.000002")).Close();
            File.Create(Path.Combine(PathName, "chunk-000005.000005")).Close();

            var strategy = new VersionedPatternFileNamingStrategy(PathName, "chunk-");
            var versions = strategy.GetAllVersionsFor(5);
            Assert.AreEqual(4, versions.Length);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000007"), versions[0]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000005"), versions[1]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000002"), versions[2]);
            Assert.AreEqual(Path.Combine(PathName, "chunk-000005.000000"), versions[3]);
        }
 public void when_getting_file_for_negative_version_throws_argumentoutofrangeexception()
 {
     var strategy = new VersionedPatternFileNamingStrategy("Path", "prefix");
     Assert.Throws<ArgumentOutOfRangeException>(() => strategy.GetFilenameFor(0, -1));
 }
 public void when_getting_file_for_nonnegative_index_and_version_appends_value_and_provided_version()
 {
     var strategy = new VersionedPatternFileNamingStrategy("path", "prefix-");
     Assert.AreEqual("path" + Path.DirectorySeparatorChar + "prefix-000001.000007", strategy.GetFilenameFor(1, 7));
 }
 public void when_getting_file_for_positive_index_and_no_version_appends_index_to_name_with_zero_version()
 {
     var strategy = new VersionedPatternFileNamingStrategy("path", "prefix-");
     Assert.AreEqual("path" + Path.DirectorySeparatorChar + "prefix-000001.000000", strategy.GetFilenameFor(1));
 }