Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Unit/Helpers/Path.cs
T
Adam Hathcock 507ded7d4a Fix shallow copy allocations and perf (#357)
* add more DynamicBase Tests

* Move ShallowCopy to dynamic and try to be faster with copy

* Correct tests for macOS

* use cache obsolete attribute

* Update src/Speckle.Sdk/Models/DynamicBase.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/Speckle.Sdk.Tests.Unit/Models/DynamicBaseTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/Speckle.Sdk.Tests.Unit/Models/DynamicBaseTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix AI

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-21 11:01:00 +01:00

82 lines
2.1 KiB
C#

using System.Runtime.InteropServices;
using FluentAssertions;
using Speckle.Sdk.Logging;
namespace Speckle.Sdk.Tests.Unit.Helpers;
public class SpecklePathTests
{
[Fact]
public void TestUserApplicationDataPath()
{
var userPath = SpecklePathProvider.UserApplicationDataPath();
string pattern;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
pattern = @"C:\\Users\\.*\\AppData\\Roaming";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
pattern = @"\/Users\/.*\/Library\/Application Support";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// if running under root user, the .config folder is in another location...
if (userPath.StartsWith("/root"))
{
pattern = @"\/root/\.config";
}
else
{
pattern = @"\/home/.*/\.config";
}
}
else
{
throw new NotImplementedException("Your OS platform is not supported");
}
userPath.Should().MatchRegex(pattern);
}
[Fact]
public void TestInstallApplicationDataPath()
{
var installPath = SpecklePathProvider.InstallApplicationDataPath;
string pattern;
if (string.IsNullOrEmpty(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)))
{
pattern = @"\/root";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// this will prob fail on windows
pattern = @"C:\\Users\\.*\\AppData\\Roaming";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
pattern = @"\/Users\/.*\/Library\/Application Support";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// if running under root user, the .config folder is in another location...
if (installPath.StartsWith("/root"))
{
pattern = @"\/root/\.config";
}
else
{
pattern = @"\/home/.*/\.config";
}
}
else
{
throw new NotImplementedException("Your OS platform is not supported");
}
installPath.Should().MatchRegex(pattern);
}
}