Esempio n. 1
0
        public void UnthrowMultiple()
        {
            var cricket = new Cricket(1);
            var segment25 = getSegment(cricket, 25);
            var player1 = cricket.Players[0];

            // Player 1, open 25 and score 100
            cricket.RegisterDart(25, 2);
            Assert.AreEqual(2, segment25.GetScoredMarks(player1));
            Assert.AreEqual(0, segment25.GetScore(player1));
            Assert.AreEqual(null, segment25.Owner);

            cricket.RegisterDart(25, 2);
            Assert.AreEqual(4, segment25.GetScoredMarks(player1));
            Assert.AreEqual(25, segment25.GetScore(player1));
            Assert.AreEqual(player1, segment25.Owner);

            cricket.RegisterDart(25, 2);
            Assert.AreEqual(6, segment25.GetScoredMarks(player1));
            Assert.AreEqual(75, segment25.GetScore(player1));
            Assert.AreEqual(player1, segment25.Owner);

            cricket.NextPlayer();
            cricket.Unthrow();
            Assert.AreEqual(4, segment25.GetScoredMarks(player1));
            Assert.AreEqual(25, segment25.GetScore(player1));
            Assert.AreEqual(player1, segment25.Owner);

            cricket.Unthrow();
            Assert.AreEqual(2, segment25.GetScoredMarks(player1));
            Assert.AreEqual(0, segment25.GetScore(player1));
            Assert.AreEqual(null, segment25.Owner);

            cricket.Unthrow();
            Assert.AreEqual(0, segment25.GetScoredMarks(player1));
            Assert.AreEqual(0, segment25.GetScore(player1));
            Assert.AreEqual(null, segment25.Owner);
        }
Esempio n. 2
0
        public void UnthrowTwoPlayer()
        {
            var cricket = new Cricket(2);

            // Player 1, open 25 and 20
            cricket.RegisterDart(25, 2);
            cricket.RegisterDart(25, 1);
            Assert.IsTrue(getSegment(cricket, 25).IsOpen);
            Assert.AreEqual(cricket.Players[0], getSegment(cricket, 25).Owner);

            cricket.RegisterDart(20, 3);
            Assert.IsTrue(getSegment(cricket, 20).IsOpen);
            Assert.AreEqual(cricket.Players[0], getSegment(cricket, 20).Owner);

            cricket.NextPlayer();

            // Player 2, close 20
            cricket.RegisterDart(20, 3);
            Assert.IsFalse(getSegment(cricket, 20).IsOpen);
            Assert.AreEqual(cricket.Players[0], getSegment(cricket, 20).Owner);

            cricket.Unthrow();
            Assert.IsTrue(getSegment(cricket, 20).IsOpen);
            Assert.AreEqual(cricket.Players[0], getSegment(cricket, 20).Owner);
        }
Esempio n. 3
0
        public void Unthrow()
        {
            var cricket = new Cricket(1);
            var player1 = cricket.Players[0];

            // Player 1, open 25
            cricket.RegisterDart(25, 1);
            Assert.AreEqual(0, cricket.GetScore(player1));

            cricket.RegisterDart(25, 2);
            Assert.AreEqual(0, cricket.GetScore(player1));

            // Player 1, score 50 points
            cricket.RegisterDart(25, 2);
            Assert.AreEqual(50, cricket.GetScore(player1));

            // Player 1, unthrow, remove last 50 points
            cricket.Unthrow();
            Assert.AreEqual(0, cricket.GetScore(player1));
        }