Skip to content

Commit

Permalink
More test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Koutanov committed Jan 23, 2024
1 parent ff294f9 commit 1c7f516
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

double idealOverround = 1.15;
Console.WriteLine("ideal overround: {0}", idealOverround);
Console.WriteLine("ideal booksum: {0}", idealOverround * fairBooksum);

IOverroundMethod[] methods = [new Multiplicative(), new Additive(), new Power(), new OddsRatio()];
foreach (var method in methods)
{
double[] odds = method.Apply(fairPrices, idealOverround);
Console.WriteLine("");
Console.WriteLine("method: {0}", method.GetType().Name);
Console.WriteLine("odds: [{0}]", string.Join(", ", odds));
Console.WriteLine("odds: [{0}], booksum: {1}", string.Join(", ", odds), Booksum.FromPrices(odds));
}
2 changes: 2 additions & 0 deletions Overround.Tests/AdditiveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void TestApplyNoOverround()
double[] fairPrices = [1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4], odds, Delta);
}

[TestMethod]
Expand Down Expand Up @@ -42,5 +43,6 @@ public void TestApplyWithFairBooksumOf2()
double[] fairPrices = [1 / 0.2, 1 / 0.4, 1 / 0.6, 1 / 0.8];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround * 2, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([3.636, 2.105, 1.481, 1.143], odds, Delta);
}
}
2 changes: 2 additions & 0 deletions Overround.Tests/MultiplicativeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void TestApplyNoOverround()
double[] fairPrices = [1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4], odds, Delta);
}

[TestMethod]
Expand Down Expand Up @@ -42,5 +43,6 @@ public void TestApplyWithFairBooksumOf2()
double[] fairPrices = [1 / 0.2, 1 / 0.4, 1 / 0.6, 1 / 0.8];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround * 2, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([4.348, 2.174, 1.449, 1.087], odds, Delta);
}
}
2 changes: 2 additions & 0 deletions Overround.Tests/OddsRatioTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void TestApplyNoOverround()
double[] fairPrices = [1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4], odds, Delta);
}

[TestMethod]
Expand Down Expand Up @@ -42,5 +43,6 @@ public void TestApplyWithFairBooksumOf2()
double[] fairPrices = [1 / 0.2, 1 / 0.4, 1 / 0.6, 1 / 0.8];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround * 2, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([3.744, 2.029, 1.457, 1.171], odds, Delta);
}
}
2 changes: 2 additions & 0 deletions Overround.Tests/PowerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void TestApplyNoOverround()
double[] fairPrices = [1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([1 / 0.1, 1 / 0.2, 1 / 0.3, 1 / 0.4], odds, Delta);
}

[TestMethod]
Expand Down Expand Up @@ -42,5 +43,6 @@ public void TestApplyWithFairBooksumOf2()
double[] fairPrices = [1 / 0.2, 1 / 0.4, 1 / 0.6, 1 / 0.8];
double[] odds = method.Apply(fairPrices, idealOverround);
Assert.AreEqual(idealOverround * 2, Booksum.FromPrices(odds), Delta);
ArrayAssert.AreEqual([3.458, 2.027, 1.483, 1.188], odds, Delta);
}
}

0 comments on commit 1c7f516

Please sign in to comment.