public void StrikeFrameCreation() { var roll1 = new Roll(10); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1 }); Assert.IsType <StrikeFrame>(frame); }
private static int NextTwoBalls(IBowlingFrame frame, IList<IBowlingFrame> frames) { var nextFrame = NextFrame(frame, frames); var secondFrame = NextFrame(nextFrame, frames); return nextFrame.First + (nextFrame.IsStrike ? secondFrame.First : nextFrame.Second); }
public void Roll(int numberOfPinsKnockedDown) { if (currentFrame == null) { currentFrame = _frameFactory.CreateFrame(); } currentFrame.Roll(numberOfPinsKnockedDown); }
public void OpenFrameCreation() { var roll1 = new Roll(4); var roll2 = new Roll(2); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1, roll2 }); Assert.IsType <OpenFrame>(frame); }
public void LastFrameCreationWith_TwoRolls() { var roll1 = new Roll(1); var roll2 = new Roll(1); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1, roll2 }, 10); Assert.IsType <LastFrame>(frame); }
public void SpareFrameCreation() { var roll1 = new Roll(5); var roll2 = new Roll(5); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1, roll2 }); Assert.IsType <SpareFrame>(frame); }
private static IBowlingFrame NextFrame(IBowlingFrame frame, IList<IBowlingFrame> frames) { var index = frames.IndexOf(frame); return index == 10 ? frame : index == -1 || index == frames.Count - 1 ? _empty : frames[index + 1]; }
public IFrameScore GetCurrentScore(IBowlingFrame currentFrame, int howManyRolls) { if (_framesQueue.Sum(frame => frame.ConsumesRolls) < howManyRolls) { return(new OpenScore()); } return(new FrameScore(currentFrame.OpenValue + _framesQueue .SelectMany(frame => frame.GetInternalFrames()) .Take(howManyRolls) .Sum(frame => frame.OpenValue))); }
public bool TryDequeue(out IBowlingFrame frame) { return(_framesQueue.TryDequeue(out frame)); }
private bool ShouldWaitForASecondBall(IBowlingFrame frame) { return !frame.IsStrike || this._frames.Count == 11; }
private static int NextBall(IBowlingFrame frame, IList<IBowlingFrame> frames) { return NextFrame(frame, frames).First; }