Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

29 lines
1.2 KiB

using System.Runtime.InteropServices;
using StabilityMatrix.Core.Models;
namespace StabilityMatrix.Tests.Models;
[TestClass]
public class InstalledPackageTests
{
[DataTestMethod]
[DataRow("C:\\User\\AppData\\StabilityMatrix", "C:\\User\\Other", null)]
[DataRow("C:\\Data", "D:\\Data\\abc", null)]
[DataRow("C:\\Data", "C:\\Data\\abc", "abc")]
[DataRow("C:\\User\\AppData\\StabilityMatrix", "C:\\User\\AppData\\StabilityMatrix\\Packages\\abc", "Packages\\abc")]
public void TestGetSubPath(string relativeTo, string path, string? expected)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
relativeTo = relativeTo.Replace("C:\\", $"{Path.DirectorySeparatorChar}")
.Replace('\\', Path.DirectorySeparatorChar);
path = path.Replace("C:\\", $"{Path.DirectorySeparatorChar}")
.Replace('\\', Path.DirectorySeparatorChar);
expected = expected?.Replace("C:\\", $"{Path.DirectorySeparatorChar}")
.Replace('\\', Path.DirectorySeparatorChar);
}
var result = InstalledPackage.GetSubPath(relativeTo, path);
Assert.AreEqual(expected, result);
}
}