public void UpdateScoreTest() { ScoreSystemInfo scoreSystem = new ScoreSystemInfo("System 1", 0); ScoreSystemMssqlContext scoreSystemContext = new ScoreSystemMssqlContext(); ScoreMssqlContext scoreContext = new ScoreMssqlContext(); try { Assert.AreEqual(0, scoreSystemContext.GetScoreSystems().Count, "Cleanup of database failed"); scoreSystemContext.AddScoreSystem(scoreSystem.Name, scoreSystem.PointsForFastestLap); scoreContext.AddOrUpdateScore(1, 10, scoreSystem); Assert.AreEqual(1, scoreContext.GetScoresForScoreSystem(scoreSystem).Count); Assert.AreEqual(10, scoreContext.GetScoresForScoreSystem(scoreSystem)[0].Points); scoreContext.AddOrUpdateScore(1, 5, scoreSystem); Assert.AreEqual(1, scoreContext.GetScoresForScoreSystem(scoreSystem).Count); Assert.AreEqual(5, scoreContext.GetScoresForScoreSystem(scoreSystem)[0].Points); } finally { scoreContext.RemoveScore(1, scoreSystem); Assert.AreEqual(0, scoreContext.GetScoresForScoreSystem(scoreSystem).Count); scoreSystemContext.RemoveScoreSystem("System 1"); Assert.AreEqual(0, scoreSystemContext.GetScoreSystems().Count, "Cleanup of database failed"); } }
public void RemoveScoreSystemTest() { ScoreSystemMssqlContext sqlContext = new ScoreSystemMssqlContext(); try { sqlContext.AddScoreSystem("System 1", 0); sqlContext.AddScoreSystem("System 2", 0); Assert.AreEqual(2, sqlContext.GetScoreSystems().Count, "There should be 2 Score systems"); sqlContext.RemoveScoreSystem("System 2"); Assert.AreEqual(1, sqlContext.GetScoreSystems().Count, "There should be 1 Score system"); } finally { sqlContext.RemoveScoreSystem("System 1"); Assert.AreEqual(0, sqlContext.GetScoreSystems().Count, "Cleanup of the database failed"); } }
public void AddScoreSystemTest() { ScoreSystemMssqlContext sqlContext = new ScoreSystemMssqlContext(); try { List <ScoreSystemInfo> scoreSystems = sqlContext.GetScoreSystems(); Assert.AreEqual(0, scoreSystems.Count, "Precondition for this test is an empty ScoreSystem table"); sqlContext.AddScoreSystem("System 1", 0); scoreSystems = sqlContext.GetScoreSystems(); Assert.AreEqual(1, scoreSystems.Count, "The number of scoresystems should be 1"); Assert.AreEqual("System 1", scoreSystems[0].Name, "The added scoresystem should be 'System 1'"); } finally { sqlContext.RemoveScoreSystem("System 1"); Assert.AreEqual(0, sqlContext.GetScoreSystems().Count, "Cleanup of database failed"); } }
public void AddScoreSystemTwiceTest() { ScoreSystemMssqlContext sqlContext = new ScoreSystemMssqlContext(); try { sqlContext.AddScoreSystem("System 1", 0); List <ScoreSystemInfo> scoreSystems = sqlContext.GetScoreSystems(); Assert.AreEqual(1, scoreSystems.Count, "There should be 1 scoresystem"); Assert.AreEqual("System 1", scoreSystems[0].Name, "The scoresystem should be System 1"); sqlContext.AddScoreSystem("System 1", 0); Assert.Fail("Adding a discipline twice should fail"); } finally { Assert.AreEqual(1, sqlContext.GetScoreSystems().Count, "Cleanup cannot be executed"); sqlContext.RemoveScoreSystem("System 1"); Assert.AreEqual(0, sqlContext.GetScoreSystems().Count, "Cleanup of the database failed"); } }
public void AddInvalidNumberOfPontsTest() { ScoreSystemMssqlContext sqlContext = new ScoreSystemMssqlContext(); sqlContext.AddScoreSystem("System 1", -1); }
public void AddEmptScoreSystemTest() { ScoreSystemMssqlContext sqlContext = new ScoreSystemMssqlContext(); sqlContext.AddScoreSystem("", 0); }