Added a test project for the Glicko class

This commit is contained in:
moosecrab 2020-02-24 23:06:04 -08:00
parent f35bb019cc
commit dabdbe501c
4 changed files with 222 additions and 0 deletions

74
GlickoTest/GlickoTest.vb Executable file
View File

@ -0,0 +1,74 @@
Imports System.Xml.Linq
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports System.Text
Imports PepperBet
<TestClass()>
Public Class GlickoTest
Private testContextInstance As TestContext
'''<summary>
'''Gets or sets the test context which provides
'''information about and functionality for the current test run.
'''</summary>
Public Property TestContext() As TestContext
Get
Return testContextInstance
End Get
Set(ByVal value As TestContext)
testContextInstance = value
End Set
End Property
#Region "Additional test attributes"
'
' You can use the following additional attributes as you write your tests:
'
' Use ClassInitialize to run code before running the first test in the class
' <ClassInitialize()> Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
' End Sub
'
' Use ClassCleanup to run code after all tests in a class have run
' <ClassCleanup()> Public Shared Sub MyClassCleanup()
' End Sub
'
' Use TestInitialize to run code before running each test
' <TestInitialize()> Public Sub MyTestInitialize()
' End Sub
'
' Use TestCleanup to run code after each test has run
' <TestCleanup()> Public Sub MyTestCleanup()
' End Sub
'
#End Region
<TestMethod()>
Public Sub TestGlickoMatchup()
Dim testman As New Glicko("testman", 0)
testman.K = 1500
testman.RD = 200
Dim opp1 As New Glicko("1", 0)
opp1.K = 1400
opp1.RD = 30
Dim opp2 As New Glicko("2", 0)
opp2.K = 1550
opp2.RD = 100
Dim opp3 As New Glicko("3", 0)
opp3.K = 1700
opp3.RD = 300
'testman.Update({opp1, opp2, opp3}, {1, 0, 0}, 0)
Glicko.UpdateBatch(testman, opp1, 1, 0, 0)
Glicko.UpdateBatch(testman, opp2, 0, 1, 0)
Glicko.UpdateBatch(testman, opp3, 0, 1, 0)
'testmans K should be 1464 and RD should be 151.4
Assert.AreEqual(testman.K, 1464.2190389663426)
Assert.AreEqual(testman.RD, 151.2537434317843)
End Sub
End Class

98
GlickoTest/GlickoTest.vbproj Executable file
View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>
</SchemaVersion>
<ProjectGuid>{E6794089-F810-402B-A3CE-0D7EA579108A}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>GlickoTest</RootNamespace>
<AssemblyName>GlickoTest</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
<ReferencePath>$(DevEnvDir)PublicAssemblies\</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>GlickoTest.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>GlickoTest.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Deployment" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Diagnostics" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="Microsoft.VisualBasic" />
<Import Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="GlickoTest.vb" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperBet\PepperBet.vbproj">
<Project>{F88AA82A-320E-4A3B-87A3-C07BFC6F3450}</Project>
<Name>PepperBet</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,37 @@
Imports System
Imports System.Reflection
Imports 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.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("GlickoTest")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("GlickoTest")>
<Assembly: AssemblyCopyright("Copyright © 2020")>
<Assembly: AssemblyTrademark("")>
<Assembly: CLSCompliant(True)>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("7116de55-d866-4034-9286-a8df9d2a8826")>
' 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")>

View File

@ -5,7 +5,14 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PepperBet", "PepperBet\Pepp
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AutoUpdater", "AutoUpdater\AutoUpdater.vbproj", "{1E99431F-65AD-4CFD-9A8A-264CED54DAEB}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GlickoTest", "GlickoTest\GlickoTest.vbproj", "{E6794089-F810-402B-A3CE-0D7EA579108A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F59519B4-43BD-4F38-A7AB-8694B5014CB2}"
EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = PepperBet.vsmdi
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
@ -29,6 +36,12 @@ Global
{1E99431F-65AD-4CFD-9A8A-264CED54DAEB}.Release|Any CPU.Build.0 = Release|Any CPU
{1E99431F-65AD-4CFD-9A8A-264CED54DAEB}.Release|x86.ActiveCfg = Release|x86
{1E99431F-65AD-4CFD-9A8A-264CED54DAEB}.Release|x86.Build.0 = Release|x86
{E6794089-F810-402B-A3CE-0D7EA579108A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6794089-F810-402B-A3CE-0D7EA579108A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6794089-F810-402B-A3CE-0D7EA579108A}.Debug|x86.ActiveCfg = Debug|Any CPU
{E6794089-F810-402B-A3CE-0D7EA579108A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6794089-F810-402B-A3CE-0D7EA579108A}.Release|Any CPU.Build.0 = Release|Any CPU
{E6794089-F810-402B-A3CE-0D7EA579108A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE