Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnakinRaW committed Jan 1, 2025
1 parent a5e6eef commit d0b9ccc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public static IEnumerable<object[]> GetBuildCommandLineTestData()

var normalMod = new ModArgument(fs.DirectoryInfo.New("with space/game/path"), gameDir, false);
var steamMod = new ModArgument(fs.DirectoryInfo.New("123456"), gameDir, true);
var expectedNormalModPath = PathNormalizer.Normalize("path", new()
{
UnifyCase = UnifyCasingKind.UpperCase,
});

yield return [new GameArgument[] { }, string.Empty];
yield return [new GameArgument[] { new TestFlagArg(false, true) }, string.Empty];
Expand All @@ -36,12 +40,12 @@ public static IEnumerable<object[]> GetBuildCommandLineTestData()
yield return [new GameArgument[] { new MapArgument("myMap") }, "MAP=myMap"];
yield return [new GameArgument[] { new WindowedArgument(), new MapArgument("myMap") }, "WINDOWED MAP=myMap"];
yield return [new GameArgument[] { new MapArgument("myMap"), new WindowedArgument() }, "MAP=myMap WINDOWED"];
yield return [new GameArgument[] { new ModArgumentList([normalMod]) }, "MODPATH=PATH"];
yield return [new GameArgument[] { new ModArgumentList([normalMod, steamMod]) }, "MODPATH=PATH STEAMMOD=123456"];
yield return [new GameArgument[] { new ModArgumentList([steamMod, normalMod]) }, "STEAMMOD=123456 MODPATH=PATH"];
yield return [new GameArgument[] { new ModArgumentList([normalMod, steamMod]), new WindowedArgument() }, "MODPATH=PATH STEAMMOD=123456 WINDOWED"];
yield return [new GameArgument[] { new ModArgumentList([normalMod]) }, $"MODPATH={expectedNormalModPath}"];
yield return [new GameArgument[] { new ModArgumentList([normalMod, steamMod]) }, $"MODPATH={expectedNormalModPath} STEAMMOD=123456"];
yield return [new GameArgument[] { new ModArgumentList([steamMod, normalMod]) }, $"STEAMMOD=123456 MODPATH={expectedNormalModPath}"];
yield return [new GameArgument[] { new ModArgumentList([normalMod, steamMod]), new WindowedArgument() }, $"MODPATH={expectedNormalModPath} STEAMMOD=123456 WINDOWED"];
yield return [new GameArgument[] { new ModArgumentList([normalMod, steamMod]), new WindowedArgument(), new MCEArgument(), new MapArgument("myMap") },
"MODPATH=PATH STEAMMOD=123456 WINDOWED -MCE MAP=myMap"];
$"MODPATH={expectedNormalModPath} STEAMMOD=123456 WINDOWED -MCE MAP=myMap"];
yield return [new GameArgument[] { new LanguageArgument(new LanguageInfo("de", LanguageSupportLevel.Default)) }, "LANGUAGE=GERMAN"];
yield return [new GameArgument[] { new MonitorArgument(42) }, "MONITOR=42"];
yield return [new GameArgument[] { new AILogStyleArgument(AILogStyle.Normal) }, "AILOGSTYLE=NORMAL"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Serialize_NotSupportedType()
}

[PlatformSpecificTheory(TestPlatformIdentifier.Linux)]
[InlineData("game/mod/my", "game", "mod\\my")]
[InlineData("game/mod/my", "game", "mod/my")]
[InlineData("game/mod", "game", "mod")]
[InlineData("game/mod", "GAME", "game/mod", true)]
[InlineData("mod", "game", "mod", true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ public void Ctor_SetProperty()
}

[Theory]
[InlineData("game/mod/my", "game", "mod\\my")]
[InlineData("game/mod", "GAME", "mod")]
[InlineData("game/mod/my", "game", "mod/my")]
[InlineData("mod", "game", "mod", true)]
[InlineData("with space/other", "with space/game", "../other", false)]
public void ValueToCommandLine_ShortenPathWindows(string targetPath, string basePath, string expected, bool makeExpectedFullPath = false)
public void ValueToCommandLine_ShortenPath(string targetPath, string basePath, string expected, bool makeExpectedFullPath = false)
{
var fs = new MockFileSystem();

if (makeExpectedFullPath)
expected = fs.Path.GetFullPath(expected).ToUpperInvariant();
expected = fs.Path.GetFullPath(expected);

expected = PathNormalizer.Normalize(expected, new PathNormalizeOptions()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@
<ProjectReference Include="..\src\PG.StarWarsGame.Infrastructure.Clients.csproj" />
</ItemGroup>

<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' != 'true'">true</IsLinux>
</PropertyGroup>

<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>Windows</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>Linux</DefineConstants>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#if Windows

using System;
using System.Collections.Generic;
using AET.SteamAbstraction;
using AET.SteamAbstraction.Games;
Expand Down Expand Up @@ -149,4 +151,6 @@ private GameDetectorTestInfo<EmptyStruct> SetupGame(

return new GameDetectorTestInfo<EmptyStruct>(gameIdentity.Type, game.Directory, default);
}
}
}

#endif

0 comments on commit d0b9ccc

Please sign in to comment.