Add unit tests! woo!

This commit is contained in:
Neo Anderson committed 2020-03-30 00:32:33 -07:00
1 parent 7c2960e1d7
commit a3f60cfd25
4 files changed
+116 -19

No files matched your search

+5 -5
View File
@@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.28307.1022
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrappeMocha", "FrappeMocha.csproj", "{04AB5523-E679-4628-8B8B-B928A5DA5107}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{EB446B1A-E322-48E8-968A-3E4C9B02454F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformUnitTests", "PlatformUnitTests\PlatformUnitTests.csproj", "{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,10 +17,10 @@ Global
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04AB5523-E679-4628-8B8B-B928A5DA5107}.Release|Any CPU.Build.0 = Release|Any CPU
{EB446B1A-E322-48E8-968A-3E4C9B02454F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB446B1A-E322-48E8-968A-3E4C9B02454F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB446B1A-E322-48E8-968A-3E4C9B02454F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB446B1A-E322-48E8-968A-3E4C9B02454F}.Release|Any CPU.Build.0 = Release|Any CPU
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEF3A8CA-7FAA-416F-A1FD-2AB221A84AF8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+104
View File
@@ -0,0 +1,104 @@
using System.Reflection;
using FrappeMocha.Keygen;
using FrappeMocha.Keygen.Platforms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PlatformUnitTests
{
[TestClass]
public class PlatformUnitTest
{
private KeygenBase platform;
private readonly string[] _testCompanyUserStrings = {"Test", "FrappeMocha", "abcd", "1234"};
[TestMethod]
public void TestWindowsPlatform()
{
platform = new PlatformWindows();
foreach (var product in platform.Products)
{
var types = platform.GenerateLicencetypes(product);
for (int i = 0; i < types.Count; i++)
{
foreach (string company in _testCompanyUserStrings)
{
var key = platform.Generate(i, company, product.Licence);
Assert.IsTrue(platform.Check(key, company, product.Licence));
}
}
}
}
[TestMethod]
public void TestMacOsxPlatform()
{
platform = new PlatformMac();
foreach (var product in platform.Products)
{
var types = platform.GenerateLicencetypes(product);
for (int i = 0; i < types.Count; i++)
{
foreach (string company in _testCompanyUserStrings)
{
var key = platform.Generate(i, company, product.Licence);
Assert.IsTrue(platform.Check(key, company, product.Licence));
}
}
}
}
[TestMethod]
public void TestAndroidPlatform()
{
platform = new PlatformAndroid();
foreach (var product in platform.Products)
{
var types = platform.GenerateLicencetypes(product);
for (int i = 0; i < types.Count; i++)
{
foreach (string company in _testCompanyUserStrings)
{
var key = platform.Generate(i, company, product.Licence);
Assert.IsTrue(platform.Check(key, company, product.Licence));
}
}
}
}
[TestMethod]
public void TestJavaPlatform()
{
platform = new PlatformJava();
foreach (var product in platform.Products)
{
var types = platform.GenerateLicencetypes(product);
for (int i = 0; i < types.Count; i++)
{
foreach (string company in _testCompanyUserStrings)
{
var key = platform.Generate(i, company, product.Licence);
Assert.IsTrue(platform.Check(key, company, product.Licence));
}
}
}
}
[TestMethod]
public void TestJavaScriptPlatform()
{
platform = new PlatformJavaScript();
foreach (var product in platform.Products)
{
var types = platform.GenerateLicencetypes(product);
for (int i = 0; i < types.Count; i++)
{
foreach (string company in _testCompanyUserStrings)
{
var key = platform.Generate(i, company, product.Licence);
Assert.IsTrue(platform.Check(key, company, product.Licence));
}
}
}
}
}
}
@@ -7,7 +7,9 @@
<ApplicationIcon />
<Win32Resource />
<OutputType>Library</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
@@ -16,4 +18,8 @@
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FrappeMocha.csproj" />
</ItemGroup>
</Project>
-13
View File
@@ -1,13 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTests
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}