consolidate and rename tests project into a single project, delete commented out tests, add a unit tests that tests a thing
This commit is contained in:
parent
d91c477e5a
commit
96b0b37673
33
BHTest.sln
33
BHTest.sln
|
@ -1,29 +1,33 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30114.105
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BizHawk", "BizHawk", "{18029756-5080-47CA-8394-29E97EBADE0A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.BizInvoke", "src\BizHawk.BizInvoke\BizHawk.BizInvoke.csproj", "{AE0D4E5A-E79D-4D61-8AAF-8C9CECA74A1D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.BizInvoke", "src\BizHawk.BizInvoke\BizHawk.BizInvoke.csproj", "{AE0D4E5A-E79D-4D61-8AAF-8C9CECA74A1D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Bizware.BizwareGL", "src\BizHawk.Bizware.BizwareGL\BizHawk.Bizware.BizwareGL.csproj", "{69A1ACDF-A462-44F8-801F-23CE83E564D7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Bizware.BizwareGL", "src\BizHawk.Bizware.BizwareGL\BizHawk.Bizware.BizwareGL.csproj", "{69A1ACDF-A462-44F8-801F-23CE83E564D7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Client.Common", "src\BizHawk.Client.Common\BizHawk.Client.Common.csproj", "{91004B3C-1291-4818-8E3E-DC137EFC222C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Client.Common", "src\BizHawk.Client.Common\BizHawk.Client.Common.csproj", "{91004B3C-1291-4818-8E3E-DC137EFC222C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Client.DiscoHawk", "src\BizHawk.Client.DiscoHawk\BizHawk.Client.DiscoHawk.csproj", "{1DA7BBBF-7E7F-4789-976B-E9673B5F680B}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Client.DiscoHawk", "src\BizHawk.Client.DiscoHawk\BizHawk.Client.DiscoHawk.csproj", "{1DA7BBBF-7E7F-4789-976B-E9673B5F680B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Client.EmuHawk", "src\BizHawk.Client.EmuHawk\BizHawk.Client.EmuHawk.csproj", "{D27DC2E0-01FA-46C0-973A-D4D9A167A1BB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Client.EmuHawk", "src\BizHawk.Client.EmuHawk\BizHawk.Client.EmuHawk.csproj", "{D27DC2E0-01FA-46C0-973A-D4D9A167A1BB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Common", "src\BizHawk.Common\BizHawk.Common.csproj", "{E27CE12D-2193-4EF2-888E-08D050DE9989}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Common", "src\BizHawk.Common\BizHawk.Common.csproj", "{E27CE12D-2193-4EF2-888E-08D050DE9989}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Emulation.Common", "src\BizHawk.Emulation.Common\BizHawk.Emulation.Common.csproj", "{6EB18E36-461F-408F-AF01-E06223E62FDE}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Emulation.Common", "src\BizHawk.Emulation.Common\BizHawk.Emulation.Common.csproj", "{6EB18E36-461F-408F-AF01-E06223E62FDE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Emulation.Cores", "src\BizHawk.Emulation.Cores\BizHawk.Emulation.Cores.csproj", "{4D54A255-1105-40EA-B6D1-9E98FAEA8DE6}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Emulation.Cores", "src\BizHawk.Emulation.Cores\BizHawk.Emulation.Cores.csproj", "{4D54A255-1105-40EA-B6D1-9E98FAEA8DE6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Emulation.DiscSystem", "src\BizHawk.Emulation.DiscSystem\BizHawk.Emulation.DiscSystem.csproj", "{4B7254EB-877B-41FE-BC4F-BCEF385AC7AB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Emulation.DiscSystem", "src\BizHawk.Emulation.DiscSystem\BizHawk.Emulation.DiscSystem.csproj", "{4B7254EB-877B-41FE-BC4F-BCEF385AC7AB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.WinForms.Controls", "src\BizHawk.WinForms.Controls\BizHawk.WinForms.Controls.csproj", "{07A75EED-B831-4114-B6C7-97E11EBF5A6E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.WinForms.Controls", "src\BizHawk.WinForms.Controls\BizHawk.WinForms.Controls.csproj", "{07A75EED-B831-4114-B6C7-97E11EBF5A6E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Version", "src\Version\Version.csproj", "{DAB862DA-7F19-4126-B814-6EDA219C4F8A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Version", "src\Version\Version.csproj", "{DAB862DA-7F19-4126-B814-6EDA219C4F8A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BHTest.BizHawk.Common", "src\BHTest.BizHawk.Common\BHTest.BizHawk.Common.csproj", "{4F509929-5B71-45B4-996C-44C1B89CB23F}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Common.Tests", "src\BHTest.BizHawk.Common\BizHawk.Common.Tests.csproj", "{4F509929-5B71-45B4-996C-44C1B89CB23F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -93,4 +97,7 @@ Global
|
|||
{07A75EED-B831-4114-B6C7-97E11EBF5A6E} = {18029756-5080-47CA-8394-29E97EBADE0A}
|
||||
{DAB862DA-7F19-4126-B814-6EDA219C4F8A} = {18029756-5080-47CA-8394-29E97EBADE0A}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {80241161-4FB4-4219-B5AE-21BCE1C2889A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project>
|
||||
<Import Project="../Common.props" />
|
||||
<Import Project="../CommonNullable.props" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="../../Common.props" />
|
||||
<Import Project="../../CommonNullable.props" />
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>$(ProjectDir)../../test_output</OutputPath>
|
||||
|
@ -12,6 +12,8 @@
|
|||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" PrivateAssets="all" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" PrivateAssets="all" />
|
||||
<PackageReference Include="JunitXml.TestLogger" Version="2.1.32" PrivateAssets="all" />
|
||||
<ProjectReference Include="$(ProjectDir)../$(MSBuildProjectName.Substring(7))/$(MSBuildProjectName.Substring(7)).csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BizHawk.Common\BizHawk.Common.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
||||
namespace BizHawk.Common.Tests.Common.StringExtensions
|
||||
{
|
||||
[TestClass]
|
||||
public class StringExtensionTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void In_CaseInsensitive()
|
||||
{
|
||||
var strArray = new[]
|
||||
{
|
||||
"Hello World"
|
||||
};
|
||||
|
||||
var actual = "hello world".In(strArray);
|
||||
Assert.IsTrue(actual);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
|
||||
namespace BizHawk.Common.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class SubstringExtensionTests
|
||||
{
|
||||
private const string abcdef = "abcdef";
|
||||
|
||||
private const string qrs = "qrs";
|
||||
|
||||
#if false
|
||||
[TestMethod]
|
||||
public void TestRemovePrefix()
|
||||
{
|
||||
Assert.AreEqual("bcdef", abcdef.RemovePrefix('a', qrs));
|
||||
Assert.AreEqual(string.Empty, "a".RemovePrefix('a', qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemovePrefix('c', qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemovePrefix('x', qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.RemovePrefix('a', qrs));
|
||||
|
||||
Assert.AreEqual("def", abcdef.RemovePrefix("abc", qrs));
|
||||
Assert.AreEqual("bcdef", abcdef.RemovePrefix("a", qrs));
|
||||
Assert.AreEqual(abcdef, abcdef.RemovePrefix(string.Empty, qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.RemovePrefix(abcdef, qrs));
|
||||
Assert.AreEqual(string.Empty, "a".RemovePrefix("a", qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemovePrefix("c", qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemovePrefix("x", qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.RemovePrefix("abc", qrs));
|
||||
}
|
||||
|
||||
// no tests for RemovePrefixOrEmpty as its implementation should match RemovePrefix
|
||||
|
||||
// no tests for RemovePrefixOrNull as its implementation should match RemovePrefix
|
||||
|
||||
[TestMethod]
|
||||
public void TestRemoveSuffix()
|
||||
{
|
||||
Assert.AreEqual("abcde", abcdef.RemoveSuffix('f', qrs));
|
||||
Assert.AreEqual(string.Empty, "f".RemoveSuffix('f', qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemoveSuffix('d', qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemoveSuffix('x', qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.RemoveSuffix('f', qrs));
|
||||
|
||||
Assert.AreEqual("abc", abcdef.RemoveSuffix("def", qrs));
|
||||
Assert.AreEqual("abcde", abcdef.RemoveSuffix("f", qrs));
|
||||
Assert.AreEqual(abcdef, abcdef.RemoveSuffix(string.Empty, qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.RemoveSuffix(abcdef, qrs));
|
||||
Assert.AreEqual(string.Empty, "f".RemoveSuffix("f", qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemoveSuffix("d", qrs));
|
||||
Assert.AreEqual(qrs, abcdef.RemoveSuffix("x", qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.RemoveSuffix("def", qrs));
|
||||
}
|
||||
|
||||
// no tests for RemoveSuffixOrEmpty as its implementation should match RemoveSuffix
|
||||
|
||||
// no tests for RemoveSuffixOrNull as its implementation should match RemoveSuffix
|
||||
|
||||
[TestMethod]
|
||||
public void TestSubstringAfter()
|
||||
{
|
||||
Assert.AreEqual("def", abcdef.SubstringAfter('c', qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringAfter('f', qrs));
|
||||
Assert.AreEqual(string.Empty, "f".SubstringAfter('f', qrs));
|
||||
Assert.AreEqual("abcdab", "abcdabcdab".SubstringAfter('d', qrs));
|
||||
Assert.AreEqual(qrs, abcdef.SubstringAfter('x', qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.SubstringAfter('c', qrs));
|
||||
|
||||
Assert.AreEqual("def", abcdef.SubstringAfter("bc", qrs));
|
||||
Assert.AreEqual(abcdef, abcdef.SubstringAfter(string.Empty, qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringAfter(abcdef, qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringAfter("f", qrs));
|
||||
Assert.AreEqual(string.Empty, "f".SubstringAfter("f", qrs));
|
||||
Assert.AreEqual("abcdab", "abcdabcdab".SubstringAfter("cd", qrs));
|
||||
Assert.AreEqual(qrs, abcdef.SubstringAfter("x", qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.SubstringAfter("abc", qrs));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestSubstringAfterLast()
|
||||
{
|
||||
// fewer tests for SubstringAfterLast as its implementation should match SubstringAfter, save for using LastIndexOf
|
||||
|
||||
Assert.AreEqual("ab", "abcdabcdab".SubstringAfterLast('d', qrs));
|
||||
Assert.AreEqual(qrs, "abcdabcdab".SubstringAfterLast('x', qrs));
|
||||
|
||||
Assert.AreEqual("ab", "abcdabcdab".SubstringAfterLast("cd", qrs));
|
||||
Assert.AreEqual(qrs, "abcdabcdab".SubstringAfterLast("x", qrs));
|
||||
}
|
||||
|
||||
// no tests for SubstringAfterLastOrEmpty as its implementation should match SubstringAfterLast
|
||||
|
||||
// no tests for SubstringAfterLastOrNull as its implementation should match SubstringAfterLast
|
||||
|
||||
// no tests for SubstringAfterOrEmpty as its implementation should match SubstringAfter
|
||||
|
||||
// no tests for SubstringAfterOrNull as its implementation should match SubstringAfter
|
||||
|
||||
[TestMethod]
|
||||
public void TestSubstringBefore()
|
||||
{
|
||||
Assert.AreEqual("abc", abcdef.SubstringBefore('d', qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringBefore('a', qrs));
|
||||
Assert.AreEqual(string.Empty, "a".SubstringBefore('a', qrs));
|
||||
Assert.AreEqual("abc", "abcdabcdab".SubstringBefore('d', qrs));
|
||||
Assert.AreEqual(qrs, abcdef.SubstringBefore('x', qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.SubstringBefore('d', qrs));
|
||||
|
||||
Assert.AreEqual("abc", abcdef.SubstringBefore("de", qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringBefore(string.Empty, qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringBefore(abcdef, qrs));
|
||||
Assert.AreEqual(string.Empty, abcdef.SubstringBefore("a", qrs));
|
||||
Assert.AreEqual(string.Empty, "a".SubstringBefore("a", qrs));
|
||||
Assert.AreEqual("ab", "abcdabcdab".SubstringBefore("cd", qrs));
|
||||
Assert.AreEqual(qrs, abcdef.SubstringBefore("x", qrs));
|
||||
Assert.AreEqual(qrs, string.Empty.SubstringBefore("def", qrs));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestSubstringBeforeLast()
|
||||
{
|
||||
// fewer tests for SubstringBeforeLast as its implementation should match SubstringBefore, save for using LastIndexOf
|
||||
|
||||
Assert.AreEqual("abcdabc", "abcdabcdab".SubstringBeforeLast('d', qrs));
|
||||
Assert.AreEqual(qrs, "abcdabcdab".SubstringBeforeLast('x', qrs));
|
||||
|
||||
Assert.AreEqual("abcdab", "abcdabcdab".SubstringBeforeLast("cd", qrs));
|
||||
Assert.AreEqual(qrs, "abcdabcdab".SubstringBeforeLast("x", qrs));
|
||||
}
|
||||
|
||||
// no tests for SubstringBeforeLastOrEmpty as its implementation should match SubstringBeforeLast
|
||||
|
||||
// no tests for SubstringBeforeLastOrNull as its implementation should match SubstringBeforeLast
|
||||
|
||||
// no tests for SubstringBeforeOrEmpty as its implementation should match SubstringBefore
|
||||
|
||||
// no tests for SubstringBeforeOrNull as its implementation should match SubstringBefore
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace BizHawk.Common.StringExtensions
|
|||
/// <returns>how many times <paramref name="c"/> appears in <paramref name="str"/>, or <c>0</c> if <paramref name="str"/> is null</returns>
|
||||
public static int HowMany(this string? str, char c) => string.IsNullOrEmpty(str) ? 0 : str.Count(t => t == c);
|
||||
|
||||
/// <returns><see langword="true"/> iff <paramref name="str"/> appears in <paramref name="options"/> (case-insensitive)</returns>
|
||||
/// <returns><see langword="true"/> if <paramref name="str"/> appears in <paramref name="options"/> (case-insensitive)</returns>
|
||||
public static bool In(this string str, params string[] options) => options.Any(opt => string.Equals(opt, str, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue