Add unit tests! woo!
This commit is contained in:
1 parent
7c2960e1d7
commit
a3f60cfd25
4 files changed
+116
-19
No files matched your search
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<ApplicationIcon />
|
||||
|
||||
<OutputType>Library</OutputType>
|
||||
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FrappeMocha.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user