Пример #1
0
        public void ScoresPassValueThrough()
        {
            var scoreB = new HighestPointsScore(1.337);
            var scoreC = new LowestTimeScore(1337);
            var scoreD = new HighestTimeScore(1337);

            Assert.AreEqual(1.337, scoreB.Points);
            Assert.AreEqual(1337, scoreC.Milliseconds);
            Assert.AreEqual(1337, scoreD.Milliseconds);
        }
Пример #2
0
        public void HighestScoreWins()
        {
            var scoreNull = (HighestPointsScore)null;

            Assert.IsNull(scoreNull + scoreNull);

            var scores = new HighestPointsScore[10];
            for (int i = 0; i < scores.Length; i++)
            {
                scores[i] = new HighestPointsScore((double)i);
            }

            for (int a = 0; a < scores.Length; a++)
            {
                var scoreA = scores[a];
                var valueA = scoreA.Points;

                Assert.IsTrue(scoreA.CompareTo(scoreNull) > 0);
                Assert.IsTrue(scoreA > scoreNull);
                Assert.IsTrue(scoreA >= scoreNull);
                Assert.IsFalse(scoreA == scoreNull);
                Assert.IsFalse(scoreA.Equals((object)scoreNull));
                Assert.IsTrue(scoreA != scoreNull);
                Assert.IsFalse(scoreA < scoreNull);
                Assert.IsFalse(scoreA <= scoreNull);

                Assert.IsFalse(scoreNull > scoreA);
                Assert.IsFalse(scoreNull >= scoreA);
                Assert.IsFalse(scoreNull == scoreA);
                Assert.IsTrue(scoreNull != scoreA);
                Assert.IsTrue(scoreNull < scoreA);
                Assert.IsTrue(scoreNull <= scoreA);

                Assert.IsTrue(scoreA == scoreA + scoreNull);
                Assert.IsTrue(scoreA == scoreNull + scoreA);

                for (int b = 0; b < scores.Length; b++)
                {
                    var scoreB = scores[b];
                    var valueB = scoreB.Points;

                    Assert.AreEqual(valueA.CompareTo(valueB), scoreA.CompareTo(scoreB));
                    Assert.AreEqual(valueA > valueB, scoreA > scoreB);
                    Assert.AreEqual(valueA >= valueB, scoreA >= scoreB);
                    Assert.AreEqual(valueA == valueB, scoreA == scoreB);
                    Assert.AreEqual(valueA != valueB, scoreA != scoreB);
                    Assert.AreEqual(valueA.Equals(valueB), scoreA.Equals((object)scoreB));
                    Assert.AreEqual(valueA <= valueB, scoreA <= scoreB);
                    Assert.AreEqual(valueA < valueB, scoreA < scoreB);
                }
            }
        }