Skip to content

Commit

Permalink
[UnitTest] Added automated test for checking if MapleLib is able to l…
Browse files Browse the repository at this point in the history
…oad older version of WZ files
  • Loading branch information
lastbattle committed Mar 4, 2022
1 parent c169162 commit b31d0c8
Show file tree
Hide file tree
Showing 18 changed files with 232 additions and 2 deletions.
25 changes: 23 additions & 2 deletions MapleHaSuite.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
# Visual Studio Version 17
VisualStudioVersion = 17.1.32203.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapleLib", "MapleLib\MapleLib.csproj", "{28AAB36D-942E-4476-A000-0E9DE380F390}"
EndProject
Expand All @@ -26,6 +26,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squishpng", "squish-1.11\vs
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squishtest", "squish-1.11\vs9\squishtest\squishtest.vcxproj", "{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{55DA028C-3222-448E-A01C-BBB5A42F586D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest_WzFile", "UnitTest_WzFile\UnitTest_WzFile.csproj", "{82A30B11-2700-4F40-B05B-9BE5DEAD522B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -174,6 +178,22 @@ Global
{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x64.Build.0 = Release|x64
{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x86.ActiveCfg = Release|Win32
{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x86.Build.0 = Release|Win32
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|Win32.ActiveCfg = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|Win32.Build.0 = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|x64.ActiveCfg = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|x64.Build.0 = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|x86.ActiveCfg = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Debug|x86.Build.0 = Debug|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|Any CPU.Build.0 = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|Win32.ActiveCfg = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|Win32.Build.0 = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|x64.ActiveCfg = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|x64.Build.0 = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|x86.ActiveCfg = Release|Any CPU
{82A30B11-2700-4F40-B05B-9BE5DEAD522B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -188,6 +208,7 @@ Global
{6A8518C3-D81A-4428-BD7F-C37933088AC1} = {BF308906-0C4D-496F-A030-FA6D3CF89563}
{3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7} = {BF308906-0C4D-496F-A030-FA6D3CF89563}
{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B} = {BF308906-0C4D-496F-A030-FA6D3CF89563}
{82A30B11-2700-4F40-B05B-9BE5DEAD522B} = {55DA028C-3222-448E-A01C-BBB5A42F586D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3544F28D-545F-4E21-B8A8-A86A825F53B5}
Expand Down
20 changes: 20 additions & 0 deletions UnitTest_WzFile/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("UnitTest_WzFile")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTest_WzFile")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("82a30b11-2700-4f40-b05b-9be5dead522b")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
67 changes: 67 additions & 0 deletions UnitTest_WzFile/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using MapleLib.WzLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;

namespace UnitTest_WzFile
{
[TestClass]
public class UnitTest1
{
private static List<Tuple<string, WzMapleVersion>> _testFiles = new List<Tuple<string, WzMapleVersion>>();

public UnitTest1()
{
// KMS
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_000_KMS_359.wz", WzMapleVersion.BMS));

// GMS
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_GMS_146.wz", WzMapleVersion.BMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_GMS_176.wz", WzMapleVersion.BMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_GMS_230.wz", WzMapleVersion.BMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_GMS_75.wz", WzMapleVersion.GMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_GMS_87.wz", WzMapleVersion.GMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_GMS_95.wz", WzMapleVersion.GMS));

// MSEA
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_SEA_135.wz", WzMapleVersion.BMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_SEA_160.wz", WzMapleVersion.BMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_SEA_211.wz", WzMapleVersion.BMS));
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_SEA_212.wz", WzMapleVersion.BMS));

// Thailand MS
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_ThaiMS_3.wz", WzMapleVersion.BMS));

// TaiwanMS
_testFiles.Add(new Tuple<string, WzMapleVersion>("TamingMob_TMS_113.wz", WzMapleVersion.EMS));
}

[TestMethod]
public void TestOlderWzFiles()
{
foreach (Tuple<string, WzMapleVersion> testFile in _testFiles)
{
string fileName = testFile.Item1;
WzMapleVersion wzMapleVerEnc = testFile.Item2;

string filePath = Path.Combine(Directory.GetCurrentDirectory(), "WzFiles", fileName);

try
{
WzFile f = new WzFile(filePath, (short) -1, wzMapleVerEnc);

WzFileParseStatus parseStatus = f.ParseWzFile();

Assert.IsFalse(parseStatus != WzFileParseStatus.Success,
"Error initializing " + fileName + " (" + parseStatus.GetErrorDescription() + ").");
}
catch (Exception e)
{
Assert.IsTrue(true,
"Error initializing " + Path.GetFileName(filePath) + " (" + e.Message + ").\r\nAlso, check that the directory is valid and the file is not in use.");
}
}
}
}
}
117 changes: 117 additions & 0 deletions UnitTest_WzFile/UnitTest_WzFile.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.7\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>{82A30B11-2700-4F40-B05B-9BE5DEAD522B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTest_WzFile</RootNamespace>
<AssemblyName>UnitTest_WzFile</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="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.7\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.7\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="WzFiles\TamingMob_SEA_212.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_ThaiMS_3.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_SEA_160.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_SEA_135.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_GMS_146.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_GMS_176.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_GMS_87.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_GMS_75.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_TMS_113.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_GMS_95.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_GMS_230.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_000_KMS_359.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="WzFiles\TamingMob_SEA_211.wz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HaSharedLibrary\HaSharedLibrary.csproj">
<Project>{5411388b-f3cb-4d52-9f55-abd15cfe966c}</Project>
<Name>HaSharedLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\MapleLib\MapleLib.csproj">
<Project>{28aab36d-942e-4476-a000-0e9de380f390}</Project>
<Name>MapleLib</Name>
</ProjectReference>
</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">
<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>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets')" />
</Project>
Binary file added UnitTest_WzFile/WzFiles/TamingMob_000_KMS_359.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_GMS_146.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_GMS_176.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_GMS_230.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_GMS_75.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_GMS_87.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_GMS_95.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_SEA_135.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_SEA_160.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_SEA_211.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_SEA_212.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_TMS_113.wz
Binary file not shown.
Binary file added UnitTest_WzFile/WzFiles/TamingMob_ThaiMS_3.wz
Binary file not shown.
5 changes: 5 additions & 0 deletions UnitTest_WzFile/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.2.7" targetFramework="net48" />
<package id="MSTest.TestFramework" version="2.2.7" targetFramework="net48" />
</packages>

0 comments on commit b31d0c8

Please sign in to comment.