acdream/tests/AcDream.App.Tests/Physics/Issue270ProductionWiringTests.cs

66 lines
1.9 KiB
C#

using System.Text.RegularExpressions;
namespace AcDream.App.Tests.Physics;
public sealed class Issue270ProductionWiringTests
{
[Fact]
public void MovementStats_UseOneEdgeTrackerAndResetItWithTheSession()
{
string source = ReadSource("Net", "LiveSessionRuntimeFactory.cs");
Assert.Contains(
"_staminaExhaustion.Observe(snapshot.CurrentStamina)",
source,
StringComparison.Ordinal);
Assert.Single(
Regex.Matches(
source,
@"controller!\.Motion\.ReportExhaustion\(\);")
.Cast<Match>());
Assert.Contains(
"_staminaExhaustion.Reset();",
source,
StringComparison.Ordinal);
}
[Fact]
public void RemoteSpawnSettle_IsRetriedAndCoversBothCreationRoutes()
{
string source = ReadSource(
"Physics",
"LiveEntityNetworkUpdateController.cs");
Assert.Contains(
"if (!remote.Body.InContact)",
source,
StringComparison.Ordinal);
Assert.Equal(
3,
Regex.Matches(source, @"SeedRemoteSpawnPlacement\(").Count);
Assert.Contains(
"RemoteSpawnPlacementSettler.TrySettle(",
source,
StringComparison.Ordinal);
}
private static string ReadSource(params string[] relativePath)
{
DirectoryInfo? directory = new(AppContext.BaseDirectory);
while (directory is not null)
{
if (File.Exists(Path.Combine(directory.FullName, "AcDream.slnx")))
{
return File.ReadAllText(Path.Combine(
directory.FullName,
"src",
"AcDream.App",
Path.Combine(relativePath)));
}
directory = directory.Parent;
}
throw new DirectoryNotFoundException("Could not find AcDream.slnx.");
}
}