refactor(tests): convert to sdk

This commit is contained in:
Anna 2021-01-02 08:08:28 -05:00
parent 4f91a848f1
commit 2b39797d98
8 changed files with 36 additions and 147 deletions

View File

@ -3,7 +3,7 @@
namespace NoSoliciting.Tests.DefinitionsTests.Chat {
public class RMT : DefinitionTest {
public RMT(DefinitionsFixture fixture) {
this.Def = fixture.defs.Chat["rmt"];
this.Def = fixture.Defs.Chat["rmt"];
}
public static object[][] DataPositives => DefUtils.DataFromMessages(new[] {

View File

@ -5,20 +5,20 @@ using System.Linq;
using Xunit;
namespace NoSoliciting.Tests.DefinitionsTests {
public class DefUtils {
public static object[][] DataFromStrings(string[] strings) => strings.Select(s => new object[] { s }).ToArray();
public static object[][] DataFromMessages(TestMessage[] messages) => messages.Select(m => new object[] { m }).ToArray();
public static class DefUtils {
public static object[][] DataFromStrings(IEnumerable<string> strings) => strings.Select(s => new object[] { s }).ToArray();
public static object[][] DataFromMessages(IEnumerable<TestMessage> messages) => messages.Select(m => new object[] { m }).ToArray();
}
public class DefinitionsFixture {
internal readonly Definitions defs;
internal Definitions Defs { get; }
public DefinitionsFixture() {
this.defs = Definitions.Load(File.ReadAllText("../../../NoSoliciting/definitions.yaml"));
this.Defs = Definitions.Load(File.ReadAllText("../../../../NoSoliciting/definitions.yaml"));
var allDefs = defs.Chat
.Concat(defs.PartyFinder)
.Concat(defs.Global);
var allDefs = this.Defs.Chat
.Concat(this.Defs.PartyFinder)
.Concat(this.Defs.Global);
foreach (var entry in allDefs) {
entry.Value.Initialise(entry.Key);
}
@ -26,19 +26,19 @@ namespace NoSoliciting.Tests.DefinitionsTests {
}
public class TestMessage {
internal ChatType channel;
internal string content;
internal ChatType Channel { get; }
internal string Content { get; }
public TestMessage(string content) : this(ChatType.None, content) { }
public TestMessage(ChatType channel, string content) {
this.content = content;
this.channel = channel;
this.Content = content;
this.Channel = channel;
}
public override string ToString() {
var name = channel == ChatType.None ? "PF" : channel.ToString();
return $"[{name}] {this.content}";
var name = this.Channel == ChatType.None ? "PF" : this.Channel.ToString();
return $"[{name}] {this.Content}";
}
}
@ -57,10 +57,10 @@ namespace NoSoliciting.Tests.DefinitionsTests {
internal static void Check(this Definition def, TestMessage message, CheckType type) {
switch (type) {
case CheckType.Positive:
Assert.True(def.Matches((XivChatType)message.channel, message.content), message.content);
Assert.True(def.Matches((XivChatType)message.Channel, message.Content), message.Content);
break;
case CheckType.Negative:
Assert.False(def.Matches((XivChatType)message.channel, message.content), message.content);
Assert.False(def.Matches((XivChatType)message.Channel, message.Content), message.Content);
break;
}
}

View File

@ -3,7 +3,7 @@
namespace NoSoliciting.Tests.DefinitionsTests.Global {
public class FreeCompany : DefinitionTest {
public FreeCompany(DefinitionsFixture fixture) {
this.Def = fixture.defs.Global["free_company"];
this.Def = fixture.Defs.Global["free_company"];
}
public static object[][] DataPositives => DefUtils.DataFromMessages(new[] {

View File

@ -3,7 +3,7 @@
namespace NoSoliciting.Tests.DefinitionsTests.PartyFinder {
public class RMT : DefinitionTest {
public RMT(DefinitionsFixture fixture) {
this.Def = fixture.defs.PartyFinder["rmt"];
this.Def = fixture.Defs.PartyFinder["rmt"];
}
public static object[][] DataPositives => DefUtils.DataFromStrings(new[] {

View File

@ -3,7 +3,7 @@
namespace NoSoliciting.Tests.DefinitionsTests.Global {
public class Roleplay : DefinitionTest {
public Roleplay(DefinitionsFixture fixture) {
this.Def = fixture.defs.Global["roleplay"];
this.Def = fixture.Defs.Global["roleplay"];
}
public static object[][] DataPositives => DefUtils.DataFromStrings(new[] {

110
NoSoliciting.Tests/NoSoliciting.Tests.csproj Normal file → Executable file
View File

@ -1,97 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.4.3\build\net452\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.4.3\build\net452\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.core.2.4.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.4.1\build\xunit.core.props')" />
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1962D91F-543A-4214-88FD-788BB7ACECE3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NoSoliciting.Tests</RootNamespace>
<AssemblyName>NoSoliciting.Tests</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Dalamud.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DefinitionsTests\Global.FreeCompany.cs" />
<Compile Include="DefinitionsTests\Chat.RMT.cs" />
<Compile Include="DefinitionsTests\DefinitionsTests.cs" />
<Compile Include="DefinitionsTests\DefinitionTest.cs" />
<Compile Include="DefinitionsTests\PartyFinder.RMT.cs" />
<Compile Include="DefinitionsTests\Roleplay.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NoSoliciting\NoSoliciting.csproj">
<Project>{e4c12987-9064-4788-8783-be418b2c0142}</Project>
<Name>NoSoliciting</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\xunit.analyzers.0.10.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
<TargetFramework>net48</TargetFramework>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.4.3\build\net452\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.4.3\build\net452\xunit.runner.visualstudio.props'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\xunit.core.2.4.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" />
</Project>
<ItemGroup>
<PackageReference Include="xunit" Version="2.4.1"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NoSoliciting\NoSoliciting.csproj"/>
</ItemGroup>
<ItemGroup>
<Reference Include="Dalamud, Version=5.2.1.1, Culture=neutral, PublicKeyToken=null">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Dalamud.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -1,20 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("NoSoliciting.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoSoliciting.Tests")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("1962d91f-543a-4214-88fd-788bb7acece3")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.1.1" targetFramework="net48" />
<package id="MSTest.TestFramework" version="2.1.1" targetFramework="net48" />
<package id="xunit" version="2.4.1" targetFramework="net48" />
<package id="xunit.abstractions" version="2.0.3" targetFramework="net48" />
<package id="xunit.analyzers" version="0.10.0" targetFramework="net48" />
<package id="xunit.assert" version="2.4.1" targetFramework="net48" />
<package id="xunit.core" version="2.4.1" targetFramework="net48" />
<package id="xunit.extensibility.core" version="2.4.1" targetFramework="net48" />
<package id="xunit.extensibility.execution" version="2.4.1" targetFramework="net48" />
<package id="xunit.runner.visualstudio" version="2.4.3" targetFramework="net48" developmentDependency="true" />
</packages>