public void RankingByClimber_GivenClimbersWithOverrideScoreboardPosition_ShouldRankByOverrideAndThenRouteCount() { // Arrange. var route1 = Route.Create("Route1"); var route2 = Route.Create("Route2"); var route3 = Route.Create("Route3"); var climberWith1Route = Climber.Create("Name1", new [] { route1 }, null); var climberWith3Routes = Climber.Create("Name2", new [] { route1, route2, route3 }, 1); var climberWith2Routes = Climber.Create("Name3", new [] { route1, route2 }, null); var climbers = new List <Climber> { climberWith1Route, climberWith3Routes, climberWith2Routes }; var testObject = new ClimberRanker(climbers); // Act. var result = testObject.RankingByClimber; // Assert. Assert.NotNull(result); Assert.AreEqual(1, result[climberWith3Routes]); Assert.AreEqual(2, result[climberWith2Routes]); Assert.AreEqual(3, result[climberWith1Route]); }
public void AnalysedClimbersInRankOrder_GivenPriorRankings_ShouldReturnCorrectDelta() { // Arrange. Climber[] climbers = { Climber.Create("Climber1", new[] { Route.Create("C1R1") }, null), Climber.Create("Climber2", new[] { Route.Create("C2R1"), Route.Create("C2R2")}, null) }; var priorAnalysisForClimber = Substitute.For <IClimberAnalysis>(); priorAnalysisForClimber.Climber.Name.Returns("Climber2"); priorAnalysisForClimber.Rank.Returns(2); var priorAnalyses = new[] { priorAnalysisForClimber }; // Act. var testObject = new Scoreboard(climbers, priorAnalyses); // Assert. Assert.AreEqual(1, testObject.AnalysedClimbersInRankOrder[0].RankDelta); }
public void RankingByClimber_GivenClimbersWithSameRouteCount_ShouldRankByRouteCount() { // Arrange. var route1 = Route.Create("Route1"); var route2 = Route.Create("Route1"); var climberWith1Route = Climber.Create("Name1", new [] { route1 }, null); var climberWith2Routes1 = Climber.Create("Name2", new [] { route1, route2 }, null); var climberWith2Routes2 = Climber.Create("Name3", new [] { route1, route2 }, null); var climbers = new List <Climber> { climberWith1Route, climberWith2Routes1, climberWith2Routes2 }; var testObject = new ClimberRanker(climbers); // Act. var result = testObject.RankingByClimber; // Assert. Assert.NotNull(result); Assert.AreEqual(1, result[climberWith2Routes1]); Assert.AreEqual(1, result[climberWith2Routes2]); Assert.AreEqual(3, result[climberWith1Route]); }
public void Create_GivenNoName_ShouldReturnNull() { // Arrange. const string name = null; Route[] routes = { Route.Create("Route1"), Route.Create("Route2") }; // Act. Climber climber = Climber.Create(name, routes, null); // Assert. Assert.Null(climber); }
public void RouteCount_GivenClimberWith3Routes_ShouldReturnReturn3() { // Arrange. const string name = "Name123"; Route[] routes = { Route.Create("Route1"), Route.Create("Route2"), Route.Create("Route3") }; // Act. Climber climber = Climber.Create(name, routes, null); // Assert. Assert.AreEqual(routes.Length, climber.RouteCount); }
public void AnalysedClimbersInRankOrder_GivenClimberWithOverrideScoreboardPositionValue_ShouldRankClimbersByRouteCountDescending() { // Arrange. Climber[] climbers = { Climber.Create("Climber1", new[] { Route.Create("C1R1") }, null), Climber.Create("Climber2", new[] { Route.Create("C2R1"), Route.Create("C2R2")}, 1), Climber.Create("Climber3", new[] { Route.Create("C3R1"), Route.Create("C3R2"), Route.Create("C3R3")}, null) }; // Act. var testObject = new Scoreboard(climbers, null); // Assert. IClimberAnalysis firstClimberAnalysis = testObject.AnalysedClimbersInRankOrder.First(); Assert.AreEqual("Climber2", firstClimberAnalysis.Climber.Name); }
public void AnalysedClimbersInRankOrder_GivenNoPriorRankings_ShouldReturnCorrectDelta() { // Arrange. Climber[] climbers = { Climber.Create("Climber1", new[] { Route.Create("C1R1") }, null), Climber.Create("Climber2", new[] { Route.Create("C2R1"), Route.Create("C2R2")}, null) }; var priorAnalyses = new ClimberAnalysis[0]; // Act. var testObject1 = new Scoreboard(climbers, priorAnalyses); var testObject2 = new Scoreboard(climbers, null); // Assert. Assert.AreEqual(0, testObject1.AnalysedClimbersInRankOrder[0].RankDelta); Assert.AreEqual(0, testObject2.AnalysedClimbersInRankOrder[0].RankDelta); }
public void GradedRoutes_GivenRoutes_ShouldReturnOnlyGradedRoutes() { // Arrange. const string name = "Name123"; Route[] routes = { Route.Create("Route1 (10)"), Route.Create("Route2"), Route.Create("Route3 (F3)") }; // Act. Climber climber = Climber.Create(name, routes, null); // Assert. Assert.True(climber.GradedRoutes.Any(r => r.Name == "Route1")); Assert.True(climber.GradedRoutes.Any(r => r.Name == "Route3")); Assert.False(climber.GradedRoutes.Any(r => r.Name == "Route2")); }
public void Create_GivenValidData_ShouldReturnNewClimber() { // Arrange. const string name = "Name123"; Route[] routes = { Route.Create("Route1"), Route.Create("Route2") }; // Act. Climber climber = Climber.Create(name, routes, null); // Assert. Assert.NotNull(climber); Assert.AreEqual(name, climber.Name); Assert.AreEqual(routes[0], climber.Routes.First()); Assert.AreEqual(routes[1], climber.Routes.Last()); }
public void AnalysedClimbersInRankOrder_GivenInputModel_ShouldRankClimbersByRouteCountDescending() { // Arrange. Climber[] climbers = { Climber.Create("Climber1", new[] { Route.Create("C1R1") }, null), Climber.Create("Climber2", new[] { Route.Create("C2R1"), Route.Create("C2R2")}, null), Climber.Create("Climber3", new[] { Route.Create("C3R1"), Route.Create("C3R2"), Route.Create("C3R3")}, null) }; // Act. var testObject = new Scoreboard(climbers, null); // Assert. IClimberAnalysis firstClimberAnalysis = testObject.AnalysedClimbersInRankOrder.First(); IClimberAnalysis lastClimberAnalysis = testObject.AnalysedClimbersInRankOrder.Last(); Assert.AreEqual("Climber3", firstClimberAnalysis.Climber.Name); Assert.AreEqual("Climber1", lastClimberAnalysis.Climber.Name); Assert.AreEqual(3, firstClimberAnalysis.Climber.RouteCount); Assert.AreEqual(1, lastClimberAnalysis.Climber.RouteCount); }