From 4a354ad17e313977ae37589d9927178a7c63e49d Mon Sep 17 00:00:00 2001 From: kalilistic <35899782+kalilistic@users.noreply.github.com> Date: Sat, 3 Apr 2021 09:15:15 -0400 Subject: [PATCH] add unit test project --- .github/workflows/main.yml | 3 ++ Dalamud.Test/Dalamud.Test.csproj | 66 +++++++++++++++++++++++++ Dalamud.Test/LocalizationTests.cs | 29 +++++++++++ Dalamud.Test/Properties/AssemblyInfo.cs | 35 +++++++++++++ Dalamud.Test/packages.config | 5 ++ Dalamud.sln | 14 ++++++ Dalamud.sln.DotSettings | 3 +- 7 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 Dalamud.Test/Dalamud.Test.csproj create mode 100644 Dalamud.Test/LocalizationTests.cs create mode 100644 Dalamud.Test/Properties/AssemblyInfo.cs create mode 100644 Dalamud.Test/packages.config diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a24e747e..8211fac31 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,9 @@ jobs: run: | cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\" .\MSBuild.exe $Env:GITHUB_WORKSPACE\Dalamud.sln /t:Build /p:Configuration=Release /p:DefineConstants=XL_NOAUTOUPDATE + - name: Run NUnit Tests + run: | + ${{github.workspace}}\packages\NUnit.ConsoleRunner.3.12.0\tools\nunit3-console.exe ${{github.workspace}}\Dalamud.Test\bin\Release\Dalamud.Test.dll - name: Upload artifact uses: actions/upload-artifact@master with: diff --git a/Dalamud.Test/Dalamud.Test.csproj b/Dalamud.Test/Dalamud.Test.csproj new file mode 100644 index 000000000..7091ebe26 --- /dev/null +++ b/Dalamud.Test/Dalamud.Test.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {C8004563-1806-4329-844F-0EF6274291FC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + Dalamud.Test + Dalamud.Test + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll + + + + + + + + + + + + {b92dab43-2279-4a2c-96e3-d9d5910edbea} + Dalamud + + + + + + diff --git a/Dalamud.Test/LocalizationTests.cs b/Dalamud.Test/LocalizationTests.cs new file mode 100644 index 000000000..7dd12b6ef --- /dev/null +++ b/Dalamud.Test/LocalizationTests.cs @@ -0,0 +1,29 @@ +using System.IO; +using System.Reflection; +using NUnit.Framework; + +namespace Dalamud.Test { + [TestFixture] + public class LocalizationTests { + private Localization localization; + private string currentLangCode; + private string workingDir; + + [OneTimeSetUp] + public void Init() { + this.workingDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + [SetUp] + public void Setup() { + this.localization = new Localization(this.workingDir); + this.localization.OnLocalizationChanged += code => this.currentLangCode = code; + } + + [Test] + public void SetupWithFallbacks_EventInvoked() { + this.localization.SetupWithFallbacks(); + Assert.AreEqual("en", this.currentLangCode); + } + } +} diff --git a/Dalamud.Test/Properties/AssemblyInfo.cs b/Dalamud.Test/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..589173bb4 --- /dev/null +++ b/Dalamud.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Dalamud.Test")] +[assembly: AssemblyDescription("Unit tests for Dalamud")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("goatcorp")] +[assembly: AssemblyProduct("Dalamud.Test")] +[assembly: AssemblyCopyright("Copyright © goatcorp 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("C8004563-1806-4329-844F-0EF6274291FC")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Dalamud.Test/packages.config b/Dalamud.Test/packages.config new file mode 100644 index 000000000..4400ea76e --- /dev/null +++ b/Dalamud.Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Dalamud.sln b/Dalamud.sln index 9b50953f7..7f125868d 100644 --- a/Dalamud.sln +++ b/Dalamud.sln @@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DalamudDebugStub", "Dalamud EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FFXIVClientStructs", "lib\FFXIVClientStructs\FFXIVClientStructs.csproj", "{3DBAEE68-9D94-4807-BCB1-E42EDD52B489}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dalamud.Test", "Dalamud.Test\Dalamud.Test.csproj", "{C8004563-1806-4329-844F-0EF6274291FC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,6 +115,18 @@ Global {3DBAEE68-9D94-4807-BCB1-E42EDD52B489}.Release|x64.Build.0 = Release|Any CPU {3DBAEE68-9D94-4807-BCB1-E42EDD52B489}.Release|x86.ActiveCfg = Release|Any CPU {3DBAEE68-9D94-4807-BCB1-E42EDD52B489}.Release|x86.Build.0 = Release|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Debug|x64.ActiveCfg = Debug|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Debug|x64.Build.0 = Debug|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Debug|x86.ActiveCfg = Debug|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Debug|x86.Build.0 = Debug|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Release|Any CPU.Build.0 = Release|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Release|x64.ActiveCfg = Release|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Release|x64.Build.0 = Release|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Release|x86.ActiveCfg = Release|Any CPU + {C8004563-1806-4329-844F-0EF6274291FC}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Dalamud.sln.DotSettings b/Dalamud.sln.DotSettings index b9b47cb53..8b8890e01 100644 --- a/Dalamud.sln.DotSettings +++ b/Dalamud.sln.DotSettings @@ -46,4 +46,5 @@ True True True - True \ No newline at end of file + True + True \ No newline at end of file