File: TestPathUtilities.cs
Web Access
Project: src\src\Razor\src\Razor\test\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Microsoft.AspNetCore.Razor.Test.Common.Tooling.csproj (Microsoft.AspNetCore.Razor.Test.Common.Tooling)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System;
using System.IO;
using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor.Utilities;
using Xunit;
 
namespace Microsoft.AspNetCore.Razor.Test.Common;
 
public static class TestPathUtilities
{
    public static string CreateRootedPath(params string[] parts)
    {
        var result = Path.Combine(parts);
 
        if (!Path.IsPathRooted(result))
        {
            result = PlatformInformation.IsWindows
                ? @"C:\" + result
                : "/" + result;
        }
 
        return result;
    }
 
    public static Uri GetUri(params string[] parts)
    {
        return new($"{Uri.UriSchemeFile}{Uri.SchemeDelimiter}{Path.Combine(parts)}");
    }
 
    public static void AssertEquivalent(string? expectedFilePath, string? actualFilePath)
    {
        Assert.True(FilePathNormalizer.AreFilePathsEquivalent(expectedFilePath, actualFilePath));
    }
}