Skip to content

Commit

Permalink
Merge pull request #516 from Mutagen-Modding/514-lower-range-id-impro…
Browse files Browse the repository at this point in the history
…vements

514 lower range id improvements
  • Loading branch information
Noggog authored Apr 9, 2024
2 parents 2af867e + 9ac27a9 commit c6a37a8
Show file tree
Hide file tree
Showing 39 changed files with 1,083 additions and 518 deletions.
3 changes: 3 additions & 0 deletions Mutagen.Bethesda.Core.UnitTests/Placeholders/TestMod.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.IO.Abstractions;
using Loqui;
using Mutagen.Bethesda.Plugins;
Expand Down Expand Up @@ -29,6 +30,8 @@ public class TestMod : ITestMod, IDisposable

IReadOnlyList<IMasterReferenceGetter> IModGetter.MasterReferences => throw new NotImplementedException();

public uint MinimumCustomFormID(bool? forceUseLowerFormIDRanges = null) => throw new NotImplementedException();

public bool CanUseLocalization { get; }
public bool UsingLocalization { get; set; }

Expand Down
137 changes: 137 additions & 0 deletions Mutagen.Bethesda.Core.UnitTests/Plugins/HeaderVersionHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using FluentAssertions;
using Mutagen.Bethesda.Plugins.Utility;
using Noggog.Testing.AutoFixture;
using Xunit;

namespace Mutagen.Bethesda.UnitTests.Plugins;

public class HeaderVersionHelperTests
{
[Theory, DefaultAutoData]
public void ForceLower(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: null,
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion + 1,
forceUseLowerFormIDRanges: null,
higherFormIdRange: 800)
.Should().Be(800);
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: null,
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion + 1,
forceUseLowerFormIDRanges: true,
higherFormIdRange: 800)
.Should().Be(1);
}

[Theory, DefaultAutoData]
public void ForceHigher(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: null,
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion - 1,
forceUseLowerFormIDRanges: null,
higherFormIdRange: 800)
.Should().Be(1);
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: null,
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion - 1,
forceUseLowerFormIDRanges: false,
higherFormIdRange: 800)
.Should().Be(800);
}

[Theory, DefaultAutoData]
public void HeaderVersionToUseLowerRelease(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: null,
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion - 1,
forceUseLowerFormIDRanges: null,
higherFormIdRange: 800)
.Should().Be(1);
}

[Theory, DefaultAutoData]
public void HeaderVersionToUseHigherRelease(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: null,
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion + 1,
forceUseLowerFormIDRanges: null,
higherFormIdRange: 800)
.Should().Be(800);
}

[Theory, DefaultAutoData]
public void AllowedRelease(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: new HashSet<GameRelease>()
{
release
},
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion - 1,
forceUseLowerFormIDRanges: null,
higherFormIdRange: 800)
.Should().Be(1);
}

[Theory, DefaultAutoData]
public void DisallowedRelease(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: new HashSet<GameRelease>()
{
},
headerVersion: headerVersion,
useLowerRangesVersion: headerVersion - 1,
forceUseLowerFormIDRanges: null,
higherFormIdRange: 800)
.Should().Be(800);
}

[Theory, DefaultAutoData]
public void ForceUseLowerRangesWithNoListedLowerVersion(
GameRelease release,
float headerVersion)
{
HeaderVersionHelper.GetNextFormId(
release,
allowedReleases: new HashSet<GameRelease>()
{
},
headerVersion: headerVersion,
useLowerRangesVersion: null,
forceUseLowerFormIDRanges: true,
higherFormIdRange: 800)
.Should().Be(1);
}
}
Loading

0 comments on commit c6a37a8

Please sign in to comment.