Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using bowlingGame;
- namespace bowlingGameTest
- {
- [TestClass]
- public class GameTest
- {
- private Game g;
- [TestInitialize]
- public void setUp()
- {
- g = new Game();
- }
- [TestMethod]
- public void TestGutterGame()
- {
- rollMany(20, 0);
- Assert.AreEqual(0, g.score());
- }
- [TestMethod]
- public void TestOnlyOnesGame()
- {
- rollMany(20, 1);
- Assert.AreEqual(20, g.score());
- }
- [TestMethod]
- public void TestStrikeGame()
- {
- g.roll(10);
- g.roll(4);
- g.roll(5);
- rollMany(16, 0);
- Assert.AreEqual(28, g.score());
- }
- [TestMethod]
- public void TestSpareGame()
- {
- rollSpare();
- g.roll(4);
- rollMany(17, 0);
- Assert.AreEqual(18, g.score());
- }
- private void rollSpare()
- {
- g.roll(5);
- g.roll(5);
- }
- private void rollMany(int count, int pins)
- {
- for (int i = 0; i < count; i++)
- {
- g.roll(pins);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement