mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Minor tweaks
pkmtests same namespace as others legalitytests assert that we check at least one file extract repo base path fetch method
This commit is contained in:
parent
7e8154fa62
commit
d681933a44
4 changed files with 26 additions and 18 deletions
|
@ -25,10 +25,7 @@ namespace PKHeX.Tests.Legality
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestFilesPassOrFailLegalityChecks()
|
public void TestFilesPassOrFailLegalityChecks()
|
||||||
{
|
{
|
||||||
var folder = Directory.GetCurrentDirectory();
|
var folder = TestUtil.GetRepoPath();
|
||||||
while (!folder.EndsWith(nameof(Tests)))
|
|
||||||
folder = Directory.GetParent(folder).FullName;
|
|
||||||
|
|
||||||
folder = Path.Combine(folder, "Legality");
|
folder = Path.Combine(folder, "Legality");
|
||||||
ParseSettings.AllowGBCartEra = true;
|
ParseSettings.AllowGBCartEra = true;
|
||||||
VerifyAll(folder, "Legal", true);
|
VerifyAll(folder, "Legal", true);
|
||||||
|
@ -41,6 +38,7 @@ namespace PKHeX.Tests.Legality
|
||||||
var path = Path.Combine(folder, name);
|
var path = Path.Combine(folder, name);
|
||||||
Directory.Exists(path).Should().BeTrue($"the specified test directory at '{path}' should exist");
|
Directory.Exists(path).Should().BeTrue($"the specified test directory at '{path}' should exist");
|
||||||
var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
|
var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
|
||||||
|
var ctr = 0;
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
var fi = new FileInfo(file);
|
var fi = new FileInfo(file);
|
||||||
|
@ -57,7 +55,10 @@ namespace PKHeX.Tests.Legality
|
||||||
ParseSettings.AllowGen1Tradeback = fi.DirectoryName.Contains("1 Tradeback");
|
ParseSettings.AllowGen1Tradeback = fi.DirectoryName.Contains("1 Tradeback");
|
||||||
var legality = new LegalityAnalysis(pkm);
|
var legality = new LegalityAnalysis(pkm);
|
||||||
legality.Valid.Should().Be(isValid, $"because the file '{fi.Directory.Name}\\{fi.Name}' should be {(isValid ? "Valid" : "Invalid")}");
|
legality.Valid.Should().Be(isValid, $"because the file '{fi.Directory.Name}\\{fi.Name}' should be {(isValid ? "Valid" : "Invalid")}");
|
||||||
|
ctr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctr.Should().BeGreaterThan(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ using FluentAssertions;
|
||||||
using PKHeX.Core;
|
using PKHeX.Core;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace PKHeX.Tests
|
namespace PKHeX.Tests.PKM
|
||||||
{
|
{
|
||||||
public static class PKMTests
|
public static class PKMTests
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,31 +5,23 @@ using Xunit;
|
||||||
|
|
||||||
namespace PKHeX.Tests.Saves
|
namespace PKHeX.Tests.Saves
|
||||||
{
|
{
|
||||||
public class SMTests
|
public static class SMTests
|
||||||
{
|
{
|
||||||
private SAV7 GetSave()
|
private static SAV7 GetSave()
|
||||||
{
|
{
|
||||||
var folder = GetRepoPath();
|
var folder = TestUtil.GetRepoPath();
|
||||||
var path = Path.Combine(folder, "TestData", "SM Project 802.main");
|
var path = Path.Combine(folder, "TestData", "SM Project 802.main");
|
||||||
return new SAV7(File.ReadAllBytes(path));
|
return new SAV7(File.ReadAllBytes(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetRepoPath()
|
|
||||||
{
|
|
||||||
var folder = Directory.GetCurrentDirectory();
|
|
||||||
while (!folder.EndsWith(nameof(Tests)))
|
|
||||||
folder = Directory.GetParent(folder).FullName;
|
|
||||||
return folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ChecksumsValid()
|
public static void ChecksumsValid()
|
||||||
{
|
{
|
||||||
GetSave().ChecksumsValid.Should().BeTrue();
|
GetSave().ChecksumsValid.Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ChecksumsUpdate()
|
public static void ChecksumsUpdate()
|
||||||
{
|
{
|
||||||
var save = GetSave();
|
var save = GetSave();
|
||||||
var originalChecksumInfo = save.ChecksumInfo;
|
var originalChecksumInfo = save.ChecksumInfo;
|
||||||
|
|
15
Tests/PKHeX.Core.Tests/Util/TestUtil.cs
Normal file
15
Tests/PKHeX.Core.Tests/Util/TestUtil.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace PKHeX.Tests
|
||||||
|
{
|
||||||
|
internal static class TestUtil
|
||||||
|
{
|
||||||
|
public static string GetRepoPath()
|
||||||
|
{
|
||||||
|
var folder = Directory.GetCurrentDirectory();
|
||||||
|
while (!folder.EndsWith(nameof(Tests)))
|
||||||
|
folder = Directory.GetParent(folder).FullName;
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue