Пример #1
0
            public void Should_Collapse_Single_Dot(string uncollapsedPath, string collapsedPath)
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath(uncollapsedPath));

                // Then
                Assert.AreEqual(collapsedPath, path);
            }
Пример #2
0
            public void Should_Throw_If_Path_Is_Null()
            {
                // Given, When
                var result = Record.Exception(() => PathCollapser.Collapse(null));

                // Then
                Assert.IsArgumentNullException(result, "path");
            }
Пример #3
0
            public void Should_Collapse_Single_Dot_To_Single_Dot(string uncollapsedPath)
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath(uncollapsedPath));

                // Then
                path.ShouldBe(".");
            }
Пример #4
0
            public void Should_Collapse_Single_Dot_With_Ellipsis()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("./.."));

                // Then
                Assert.AreEqual(".", path);
            }
Пример #5
0
            public void Should_Collapse_Path_With_Separated_Ellipsis()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("hello/temp/../temp2/../world"));

                // Then
                Assert.Equal("hello/world", path);
            }
Пример #6
0
            public void Should_Collapse_Single_Dot_With_Ellipsis()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("./.."));

                // Then
                path.ShouldBe(".");
            }
Пример #7
0
            public void Should_Collapse_Path_With_Windows_Root()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("c:/hello/temp/test/../../world"));

                // Then
                path.ShouldBe("c:/hello/world");
            }
Пример #8
0
            public void Should_Stop_Collapsing_When_Windows_Root_Is_Reached()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("c:/../../../../../../temp"));

                // Then
                path.ShouldBe("c:/temp");
            }
Пример #9
0
            public void Should_Collapse_Path_With_Non_Windows_Root()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("/hello/temp/test/../../world"));

                // Then
                Assert.Equal("/hello/world", path);
            }
Пример #10
0
            public void Should_Collapse_Relative_Path()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("hello/temp/test/../../world"));

                // Then
                Assert.Equal("hello/world", path);
            }
Пример #11
0
            public void Should_Stop_Collapsing_When_Root_Is_Reached()
            {
                // Given, When
                var path = PathCollapser.Collapse(new DirectoryPath("/hello/../../../../../../temp"));

                // Then
                Assert.Equal("/temp", path);
            }
Пример #12
0
            public void Should_Throw_If_Path_Is_Null()
            {
                // Given, When
                var result = Assert.Catch(() => PathCollapser.Collapse(null));

                // Then
                Assert.That(result, Is.TypeOf <ArgumentNullException>());
                Assert.That(((ArgumentNullException)result).ParamName, Is.EqualTo("path"));
            }
Пример #13
0
                public void Should_Collapse_Ellipsis(string input,
                                                     string expected)
                {
                    // Given, When
                    var path = PathCollapser.Collapse(new DirectoryPath(input));

                    // Then
                    Assert.Equal(expected, path);
                }
Пример #14
0
            public void Should_Throw_If_Path_Is_Null()
            {
                // Given, When
                var result = Record.Exception(() => PathCollapser.Collapse(null));

                // Then
                result.ShouldBeOfType <ArgumentNullException>()
                .And().ParamName.ShouldBe("path");
            }
Пример #15
0
                public void Should_Collapse_To_Dot_When_Only_One_Folder_Is_Followed_By_Ellipsis(string input,
                                                                                                string expected)
                {
                    // Given, When
                    var path = PathCollapser.Collapse(new DirectoryPath(input));

                    // Then
                    Assert.Equal(expected, path);
                }
Пример #16
0
            public void Should_Throw_If_Path_Is_Null()
            {
                // Given, When
                var result = Record.Exception(() => PathCollapser.Collapse(null));

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("path", ((ArgumentNullException)result).ParamName);
            }
Пример #17
0
 /// <summary>
 /// Collapses a <see cref="FilePath"/> containing ellipses.
 /// </summary>
 /// <returns>A collapsed <see cref="FilePath"/>.</returns>
 public FilePath Collapse()
 {
     return(new FilePath(PathCollapser.Collapse(this)));
 }
Пример #18
0
 /// <summary>
 /// Collapses a <see cref="DirectoryPath"/> containing ellipses.
 /// </summary>
 /// <returns>A collapsed <see cref="DirectoryPath"/>.</returns>
 public DirectoryPath Collapse()
 {
     return(new DirectoryPath(PathCollapser.Collapse(this)));
 }
Пример #19
0
 /// <summary>
 /// Collapses a <see cref="Path"/> containing ellipses.
 /// </summary>
 /// <returns>A collapsed <see cref="Path"/>.</returns>
 public Path Collapse()
 {
     return(new Path(PathCollapser.Collapse(this)));
 }