PepperBet/GlickoTest/GlickoTest.vb

75 lines
2.2 KiB
VB.net
Raw Normal View History

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