Permalink
Browse files

Tests for 8x4 games without stats

  • Loading branch information...
dlidstrom committed Mar 26, 2012
1 parent 11d7b7f commit a62059f9741b7fd308b7a1261764156297f429c2
Showing with 43 additions and 4 deletions.
  1. +35 −0 Snittlistan.Test/HomeController_Player.cs
  2. +4 −0 Snittlistan.Test/PlayerStat_Test.cs
  3. +4 −4 Snittlistan/Models/Game8x4.cs
@@ -83,5 +83,40 @@ public void Handles4x4Correctly()
result.Last20.Pins.ShouldBe(561.0 / 4);
result.Last20.Score.ShouldBe(0.25);
}
+
+ [Fact]
+ public void Handles8x4Correctly()
+ {
+ // Arrange
+ Session.Store(DbSeed.Create8x4Match());
+
+ Session.SaveChanges();
+ Session.Query<Player_ByMatch.Result, Player_ByMatch>()
+ .Customize(x => x.WaitForNonStaleResults())
+ .ToList();
+ Session.Query<Matches_PlayerStats.Result, Matches_PlayerStats>()
+ .Customize(x => x.WaitForNonStaleResults())
+ .ToList();
+ Session.Query<Pins_Last20.Result, Pins_Last20>()
+ .Customize(x => x.WaitForNonStaleResults())
+ .ToList();
+ var controller = new HomeController(Session);
+
+ // Act
+ var result = controller.Player("Mikael Axelsson").Model as PlayerMatchesViewModel;
+
+ // Assert
+ result.ShouldNotBeNull("Expected PlayerMatchesViewModel");
+ result.AverageStrikes.ShouldBe(5.0);
+ result.AverageMisses.ShouldBe(2.0);
+ result.Last20.GamesWithStats.ShouldBe(1);
+ result.Last20.Max.ShouldBe(202);
+ result.Last20.AverageStrikes.ShouldBe(5.0);
+ result.Last20.AverageMisses.ShouldBe(2.0);
+ result.Last20.AverageOnePinMisses.ShouldBe(1.0);
+ result.Last20.AverageSplits.ShouldBe(2.0);
+ result.Last20.Pins.ShouldBe(845.0 / 4);
+ result.Last20.Score.ShouldBe(0.25);
+ }
}
}
@@ -33,6 +33,10 @@ public void VerifyIndex8x4()
stats.OnePinMisses.ShouldBe(1.0);
stats.Splits.ShouldBe(2.0);
stats.AveragePins.ShouldBe(211.25);
+ stats.AverageStrikes.ShouldBe(5.0);
+ stats.AverageMisses.ShouldBe(2.0);
+ stats.AverageOnePinMisses.ShouldBe(1);
+ stats.AverageSplits.ShouldBe(2);
stats.CoveredAll.ShouldBe(1);
}
@@ -29,22 +29,22 @@ public Game8x4(string player, int pins)
/// <summary>
/// Gets or sets the number of strikes.
/// </summary>
- public int Strikes { get; set; }
+ public int? Strikes { get; set; }
/// <summary>
/// Gets or sets the number of misses.
/// </summary>
- public int Misses { get; set; }
+ public int? Misses { get; set; }
/// <summary>
/// Gets or sets the number of one-pin misses.
/// </summary>
- public int OnePinMisses { get; set; }
+ public int? OnePinMisses { get; set; }
/// <summary>
/// Gets or sets the number of splits.
/// </summary>
- public int Splits { get; set; }
+ public int? Splits { get; set; }
/// <summary>
/// Gets or sets a value indicating whether all frames were covered (no misses).

0 comments on commit a62059f

Please sign in to comment.