Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using bowlingGame;
  3.  
  4. namespace bowlingGameTest
  5. {
  6. [TestClass]
  7. public class GameTest
  8. {
  9. private Game g;
  10.  
  11. [TestInitialize]
  12. public void setUp()
  13. {
  14. g = new Game();
  15. }
  16.  
  17. [TestMethod]
  18. public void TestGutterGame()
  19. {
  20. rollMany(20, 0);
  21. Assert.AreEqual(0, g.score());
  22. }
  23.  
  24. [TestMethod]
  25. public void TestOnlyOnesGame()
  26. {
  27. rollMany(20, 1);
  28. Assert.AreEqual(20, g.score());
  29. }
  30.  
  31. [TestMethod]
  32. public void TestStrikeGame()
  33. {
  34. g.roll(10);
  35. g.roll(4);
  36. g.roll(5);
  37. rollMany(16, 0);
  38. Assert.AreEqual(28, g.score());
  39. }
  40.  
  41. [TestMethod]
  42. public void TestSpareGame()
  43. {
  44. rollSpare();
  45. g.roll(4);
  46. rollMany(17, 0);
  47. Assert.AreEqual(18, g.score());
  48. }
  49.  
  50. private void rollSpare()
  51. {
  52. g.roll(5);
  53. g.roll(5);
  54. }
  55.  
  56. private void rollMany(int count, int pins)
  57. {
  58. for (int i = 0; i < count; i++)
  59. {
  60. g.roll(pins);
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement