示例#1
0
        public void FrameWithStrikeThrowIsDone()
        {
            var frame = new Frame();

            frame.AddThrow(10);

            Assert.AreEqual(true, frame.IsDone());
        }
示例#2
0
        public void FrameWithOneRegularThrowIsNotDone()
        {
            var frame = new Frame();

            frame.AddThrow(1);

            Assert.AreEqual(false, frame.IsDone());
        }
示例#3
0
        public void FrameWithStrikeIsStrike()
        {
            var frame = new Frame();

            frame.AddThrow(10);

            Assert.IsTrue(frame.IsStrike());
        }
示例#4
0
        private Frame AddNewFrame()
        {
            var frame = new Frame();

            _frames.Add(frame);

            return frame;
        }
示例#5
0
        public void FrameWithTwoRegularThrowIsDone()
        {
            var frame = new Frame();

            frame.AddThrow(1);
            frame.AddThrow(1);

            Assert.AreEqual(true, frame.IsDone());
        }
示例#6
0
        public void FrameWithSpareThrowIsDone()
        {
            var frame = new Frame();

            frame.AddThrow(4);
            frame.AddThrow(6);

            Assert.AreEqual(true, frame.IsDone());
        }
示例#7
0
        public void FrameWithSpareIsSpare()
        {
            var frame = new Frame();

            frame.AddThrow(4);
            frame.AddThrow(6);

            Assert.IsTrue(frame.IsSpare());
        }
示例#8
0
        public void FrameWithNoThrowsIsNotStrike()
        {
            var frame = new Frame();

            Assert.IsFalse(frame.IsStrike());
        }
示例#9
0
        private int CalculateScore(Frame frame, int currentFrameNumber)
        {
            int score = frame.ScoreInFrame();

            if (frame.IsSpare())
            {
                score += CalculateSpareScore(currentFrameNumber);
            }
            else if (frame.IsStrike())
            {
                score += CalculateStrikeScore(currentFrameNumber);
            }

            return score;
        }