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:
Kurt 2019-03-18 19:33:56 -07:00
parent 7e8154fa62
commit d681933a44
4 changed files with 26 additions and 18 deletions

View file

@ -25,10 +25,7 @@ namespace PKHeX.Tests.Legality
[Fact]
public void TestFilesPassOrFailLegalityChecks()
{
var folder = Directory.GetCurrentDirectory();
while (!folder.EndsWith(nameof(Tests)))
folder = Directory.GetParent(folder).FullName;
var folder = TestUtil.GetRepoPath();
folder = Path.Combine(folder, "Legality");
ParseSettings.AllowGBCartEra = true;
VerifyAll(folder, "Legal", true);
@ -41,6 +38,7 @@ namespace PKHeX.Tests.Legality
var path = Path.Combine(folder, name);
Directory.Exists(path).Should().BeTrue($"the specified test directory at '{path}' should exist");
var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
var ctr = 0;
foreach (var file in files)
{
var fi = new FileInfo(file);
@ -57,7 +55,10 @@ namespace PKHeX.Tests.Legality
ParseSettings.AllowGen1Tradeback = fi.DirectoryName.Contains("1 Tradeback");
var legality = new LegalityAnalysis(pkm);
legality.Valid.Should().Be(isValid, $"because the file '{fi.Directory.Name}\\{fi.Name}' should be {(isValid ? "Valid" : "Invalid")}");
ctr++;
}
ctr.Should().BeGreaterThan(0);
}
}
}

View file

@ -4,7 +4,7 @@ using FluentAssertions;
using PKHeX.Core;
using Xunit;
namespace PKHeX.Tests
namespace PKHeX.Tests.PKM
{
public static class PKMTests
{

View file

@ -5,31 +5,23 @@ using Xunit;
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");
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]
public void ChecksumsValid()
public static void ChecksumsValid()
{
GetSave().ChecksumsValid.Should().BeTrue();
}
[Fact]
public void ChecksumsUpdate()
public static void ChecksumsUpdate()
{
var save = GetSave();
var originalChecksumInfo = save.ChecksumInfo;

View 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;
}
}
}