From 322e357d20373bac4a4b3805599fd6938c68189a Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Tue, 9 Apr 2024 15:49:17 -0500 Subject: [PATCH] HeaderVersionHelperTests --- .../Plugins/HeaderVersionHelperTests.cs | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Mutagen.Bethesda.Core.UnitTests/Plugins/HeaderVersionHelperTests.cs diff --git a/Mutagen.Bethesda.Core.UnitTests/Plugins/HeaderVersionHelperTests.cs b/Mutagen.Bethesda.Core.UnitTests/Plugins/HeaderVersionHelperTests.cs new file mode 100644 index 000000000..fbeafd372 --- /dev/null +++ b/Mutagen.Bethesda.Core.UnitTests/Plugins/HeaderVersionHelperTests.cs @@ -0,0 +1,120 @@ +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() + { + 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() + { + }, + headerVersion: headerVersion, + useLowerRangesVersion: headerVersion - 1, + forceUseLowerFormIDRanges: null, + higherFormIdRange: 800) + .Should().Be(800); + } +}