mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
More passing Tests
This commit is contained in:
parent
1c9610dde1
commit
3188b433eb
@ -674,6 +674,11 @@ namespace Wabbajack.Common
|
||||
{
|
||||
return HashCode.Combine(BaseHash, Paths);
|
||||
}
|
||||
|
||||
public static HashRelativePath FromStrings(string hash, params string[] paths)
|
||||
{
|
||||
return new HashRelativePath(Hash.FromBase64(hash), paths.Select(p => (RelativePath)p).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public struct FullPath : IEquatable<FullPath>, IPath
|
||||
|
@ -1,91 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib;
|
||||
using Xunit;
|
||||
|
||||
namespace Wabbajack.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class ABatchProcessorTests
|
||||
{
|
||||
#region CalculateThreadsToUse
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Manual_OverRecommended()
|
||||
{
|
||||
Assert.AreEqual(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: true,
|
||||
manualMax: byte.MaxValue,
|
||||
targetUsage: 1.0d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Manual_NeedsTrimming()
|
||||
{
|
||||
Assert.AreEqual(5, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(5, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: true,
|
||||
manualMax: 5,
|
||||
targetUsage: 1.0d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Manual_Zero()
|
||||
{
|
||||
Assert.AreEqual(1, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(1, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: true,
|
||||
manualMax: 0,
|
||||
targetUsage: 1.0d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Auto_Full()
|
||||
{
|
||||
Assert.AreEqual(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: false,
|
||||
manualMax: byte.MaxValue,
|
||||
targetUsage: 1.0d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Auto_Half()
|
||||
{
|
||||
Assert.AreEqual(4, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(4, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: false,
|
||||
manualMax: byte.MaxValue,
|
||||
targetUsage: 0.5d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Auto_Zero()
|
||||
{
|
||||
Assert.AreEqual(1, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(1, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: false,
|
||||
manualMax: byte.MaxValue,
|
||||
targetUsage: 0d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Auto_OverAllowed()
|
||||
{
|
||||
Assert.AreEqual(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: false,
|
||||
manualMax: byte.MaxValue,
|
||||
targetUsage: 2d));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public void Auto_UnderAllowed()
|
||||
{
|
||||
Assert.AreEqual(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
Assert.Equal(8, ABatchProcessor.CalculateThreadsToUse(
|
||||
recommendedCount: 8,
|
||||
manual: false,
|
||||
manualMax: byte.MaxValue,
|
||||
|
@ -1,28 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Lib.CompilationSteps;
|
||||
|
||||
namespace Wabbajack.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class CompilationStackTests : ACompilerTest
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task TestStackSerialization()
|
||||
{
|
||||
var profile = utils.AddProfile();
|
||||
var mod = utils.AddMod("test");
|
||||
|
||||
utils.Configure();
|
||||
var compiler = await ConfigureAndRunCompiler(profile);
|
||||
var stack = compiler.MakeStack();
|
||||
|
||||
var serialized = Serialization.Serialize(stack);
|
||||
var rounded = Serialization.Serialize(Serialization.Deserialize(serialized, compiler));
|
||||
|
||||
Assert.AreEqual(serialized, rounded);
|
||||
|
||||
Assert.IsNotNull(compiler.GetStack());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
using Wabbajack.Common;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Wabbajack.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class ContentRightsManagementTests
|
||||
public class ContentRightsManagementTests : IDisposable
|
||||
{
|
||||
private ValidateModlist validate;
|
||||
private WorkQueue queue;
|
||||
|
||||
|
||||
private static string permissions = @"
|
||||
|
||||
bill:
|
||||
Permissions:
|
||||
CanExtractBSAs: false
|
||||
Games:
|
||||
Skyrim:
|
||||
Permissions:
|
||||
CanModifyESPs: false
|
||||
Mods:
|
||||
42:
|
||||
Permissions:
|
||||
CanModifyAssets: false
|
||||
Files:
|
||||
33:
|
||||
Permissions:
|
||||
CanUseInOtherGames: false
|
||||
";
|
||||
|
||||
private static string server_whitelist = @"
|
||||
|
||||
GoogleIDs:
|
||||
@ -48,21 +26,21 @@ namespace Wabbajack.Test
|
||||
";
|
||||
|
||||
|
||||
[TestInitialize]
|
||||
public void TestSetup()
|
||||
public ContentRightsManagementTests()
|
||||
{
|
||||
queue = new WorkQueue();
|
||||
validate = new ValidateModlist();
|
||||
validate.LoadServerWhitelist(server_whitelist);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
public void Dispose()
|
||||
{
|
||||
queue?.Dispose();
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
[Fact]
|
||||
public async Task TestModValidation()
|
||||
{
|
||||
var modlist = new ModList
|
||||
@ -86,8 +64,8 @@ namespace Wabbajack.Test
|
||||
{
|
||||
new FromArchive
|
||||
{
|
||||
ArchiveHashPath = new[] {"DEADBEEF", "foo\\bar\\baz.pex"},
|
||||
To = "foo\\bar\\baz.pex"
|
||||
ArchiveHashPath = HashRelativePath.FromStrings(Hash.FromULong(42).ToBase64(), "foo\\bar\\baz.pex"),
|
||||
To = (RelativePath)"foo\\bar\\baz.pex"
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -99,7 +77,7 @@ namespace Wabbajack.Test
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
var errors = await validate.Validate(modlist);
|
||||
Assert.AreEqual(1, errors.Count());
|
||||
Assert.Single(errors);
|
||||
|
||||
// Ok due to file downloaded from whitelisted 3rd party
|
||||
modlist.GameType = Game.Skyrim;
|
||||
@ -109,7 +87,7 @@ namespace Wabbajack.Test
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
errors = await validate.Validate(modlist);
|
||||
Assert.AreEqual(0, errors.Count());
|
||||
Assert.Empty(errors);
|
||||
|
||||
|
||||
// Error due to file downloaded from bad 3rd party
|
||||
@ -120,7 +98,7 @@ namespace Wabbajack.Test
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
errors = await validate.Validate(modlist);
|
||||
Assert.AreEqual(errors.Count(), 1);
|
||||
Assert.Single(errors);
|
||||
|
||||
// Ok due to file downloaded from good google site
|
||||
modlist.GameType = Game.Skyrim;
|
||||
@ -130,11 +108,11 @@ namespace Wabbajack.Test
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
errors = await validate.Validate(modlist);
|
||||
Assert.AreEqual(0, errors.Count());
|
||||
Assert.Empty(errors);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Fact]
|
||||
public async Task CanLoadFromGithub()
|
||||
{
|
||||
using (var workQueue = new WorkQueue())
|
||||
|
@ -12,12 +12,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Readme.md" />
|
||||
<Compile Remove="ABatchProcessorTests.cs" />
|
||||
<None Include="ABatchProcessorTests.cs" />
|
||||
<Compile Remove="AVortexCompilerTest.cs" />
|
||||
<None Include="AVortexCompilerTest.cs" />
|
||||
<Compile Remove="ContentRightsManagementTests.cs" />
|
||||
<None Include="ContentRightsManagementTests.cs" />
|
||||
<Compile Remove="DownloaderTests.cs" />
|
||||
<None Include="DownloaderTests.cs" />
|
||||
<Compile Remove="EndToEndTests.cs" />
|
||||
@ -39,7 +35,6 @@
|
||||
<Compile Remove="ZEditIntegrationTests.cs" />
|
||||
<None Include="ZEditIntegrationTests.cs" />
|
||||
<Compile Remove="CompilationStackTests.cs" />
|
||||
<None Include="CompilationStackTests.cs" />
|
||||
<Compile Remove="FilePickerTests.cs" />
|
||||
<None Include="FilePickerTests.cs" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user