コード例 #1
0
        public void RelativizePath_TwoSubFolders()
        {
            var commonPath = @"C:\Users\developer\src\project\repo";
            var longerPath = @"C:\Users\developer\src\project\repo\sub\folder";

            var actual = PathExtensions.RelativizePath(commonPath, longerPath);

            Assert.AreEqual("sub/folder", actual);
        }
コード例 #2
0
        public void RelativizePath_Incompatible()
        {
            var commonPath = @"C:\Users\user\src\project\repo";
            var longerPath = @"C:\Users\developer\src\project\repo\sub";

            var e = Assert.ThrowsException <ArgumentException>(() =>
            {
                PathExtensions.RelativizePath(commonPath, longerPath);
            });

            StringAssert.Contains(e.Message, @"repo\sub' does not start with 'C:\Users\user");
        }