Skip to content

Commit

Permalink
fixed wlb unpacking, added tests, updated to 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Nov 27, 2024
1 parent ddefc47 commit 291ff25
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
3 changes: 1 addition & 2 deletions src/Addons/Providers/InstalledAddonsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,7 @@ or GameEnum.NAM
//need to unpack addons that contain custom RFF files
unpackedTo = Unpack(pathToFile, archive);
}

if (addonDto.Executables is not null)
else if (addonDto.Executables is not null)
{
//need to unpack addons with custom executables
unpackedTo = Unpack(pathToFile, archive);
Expand Down
25 changes: 25 additions & 0 deletions src/Tests/AddonFilesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ public sealed class AddonFilesTests : IDisposable
public AddonFilesTests()
{
var game = new Mock<IGame>();
_ = game.Setup(x => x.GameEnum).Returns(Common.Enums.GameEnum.Blood);

var config = new Mock<IConfigProvider>();
_ = config.Setup(x => x.DisabledAutoloadMods).Returns([]);

var logger = new Mock<ILogger>();

_installedAddonsProvider = new(game.Object, config.Object, logger.Object);

Check warning on line 27 in src/Tests/AddonFilesTests.cs

View workflow job for this annotation

GitHub Actions / Build_and_Test

'InstalledAddonsProvider.InstalledAddonsProvider(IGame, IConfigProvider, ILogger)' is obsolete: 'Don't create directly. Use InstalledAddonsProvider.'

Check warning on line 27 in src/Tests/AddonFilesTests.cs

View workflow job for this annotation

GitHub Actions / Build_and_Test_Linux

'InstalledAddonsProvider.InstalledAddonsProvider(IGame, IConfigProvider, ILogger)' is obsolete: 'Don't create directly. Use InstalledAddonsProvider.'
Expand Down Expand Up @@ -120,4 +123,26 @@ public async Task GrpInfoTest()
Assert.True(Directory.Exists(pathToFile.Replace(".zip", "")));
Assert.True(File.Exists(Path.Combine(pathToFile.Replace(".zip", ""), "addons.grpinfo")));
}

[Fact]
public async Task WhatLiesBeneathTest()
{
_ = Directory.CreateDirectory("FilesTemp");
File.Copy(Path.Combine("Files", "WhatLiesBeneathAddon.zip"), Path.Combine("FilesTemp", "WhatLiesBeneathAddon.zip"));

var pathToFile = Path.Combine(Directory.GetCurrentDirectory(), "FilesTemp", "WhatLiesBeneathAddon.zip");

var result = await (Task<Dictionary<AddonVersion, IAddon>>)_getAddonsFromFilesAsync.Invoke(_installedAddonsProvider, [(object)new List<string>() { pathToFile }])!;

_ = Assert.Single(result);

var a = result.First();

Assert.Equal("blood-what-lies-beneath", a.Key.Id);
Assert.Equal("1.1.7", a.Key.Version);
Assert.Equal("What Lies Beneath", a.Value.Title);

Assert.False(File.Exists(pathToFile));
Assert.True(Directory.Exists(pathToFile.Replace(".zip", "")));
}
}
Binary file added src/Tests/Files/WhatLiesBeneathAddon.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<None Remove="Files\GrpInfoAddon.zip" />
<None Remove="Files\TEST.MAP" />
<None Remove="Files\UnpackedAddon.zip" />
<None Remove="Files\WhatLiesBeneathAddon.zip" />
<None Remove="Files\ZippedAddon.zip" />
</ItemGroup>

Expand Down Expand Up @@ -42,6 +43,9 @@
<Content Include="Files\UnpackedAddon.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Files\WhatLiesBeneathAddon.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Files\ZippedAddon.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down

0 comments on commit 291ff25

Please sign in to comment.