Example #1
0
        public void GetPathNameRelativeToBaseDirectory()
        {
            var formatter = new CommandLineDiagnosticFormatter(
                baseDirectory: @"X:\rootdir\dir",
                displayFullPaths: true,
                displayEndLocations: true
                );

            Assert.Equal(@"a.cs", formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\a.cs"));
            Assert.Equal(
                @"temp\a.cs",
                formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\temp\a.cs")
                );
            Assert.Equal(
                @"Y:\rootdir\dir\a.cs",
                formatter.RelativizeNormalizedPath(@"Y:\rootdir\dir\a.cs")
                );

            formatter = new CommandLineDiagnosticFormatter(
                baseDirectory: @"X:\rootdir\..\rootdir\dir",
                displayFullPaths: true,
                displayEndLocations: true
                );

            Assert.Equal(@"a.cs", formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\a.cs"));
            Assert.Equal(
                @"temp\a.cs",
                formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\temp\a.cs")
                );
            Assert.Equal(
                @"Y:\rootdir\dir\a.cs",
                formatter.RelativizeNormalizedPath(@"Y:\rootdir\dir\a.cs")
                );
        }
Example #2
0
        public void RelativizeNormalizedPathShouldHandleDirectoriesWithSamePrefix_2()
        {
            var formatter = new CommandLineDiagnosticFormatter(
                baseDirectory: @"C:\ABCD",
                displayFullPaths: false,
                displayEndLocations: false);

            Assert.Equal(@"c:\AB\file.cs", formatter.RelativizeNormalizedPath(@"c:\AB\file.cs"));
        }
Example #3
0
        public void RelativizeNormalizedPathShouldHandleRootPaths_2()
        {
            var formatter = new CommandLineDiagnosticFormatter(
                baseDirectory: @"C:\A\B",
                displayFullPaths: false,
                displayEndLocations: false);

            Assert.Equal(@"C\D\temp.cs", formatter.RelativizeNormalizedPath(@"c:\A\B\C\D\temp.cs"));
        }
        public void GetPathNameRelativeToBaseDirectory()
        {
            var formatter = new CommandLineDiagnosticFormatter(
                baseDirectory: @"X:\rootdir\dir",
                displayFullPaths: true,
                displayEndLocations: true);

            Assert.Equal(@"a.cs", formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\a.cs"));
            Assert.Equal(@"temp\a.cs", formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\temp\a.cs"));
            Assert.Equal(@"Y:\rootdir\dir\a.cs", formatter.RelativizeNormalizedPath(@"Y:\rootdir\dir\a.cs"));

            formatter = new CommandLineDiagnosticFormatter(
                baseDirectory: @"X:\rootdir\..\rootdir\dir",
                displayFullPaths: true,
                displayEndLocations: true);

            Assert.Equal(@"a.cs", formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\a.cs"));
            Assert.Equal(@"temp\a.cs", formatter.RelativizeNormalizedPath(@"X:\rootdir\dir\temp\a.cs"));
            Assert.Equal(@"Y:\rootdir\dir\a.cs", formatter.RelativizeNormalizedPath(@"Y:\rootdir\dir\a.cs"));
        }