-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed Assignment #84
base: master
Are you sure you want to change the base?
Changes from 25 commits
0097741
1c7085f
e9fbeae
daa719b
aac69f7
096f89b
742283f
4dec522
1848520
c3ce58a
f88b64a
f5a7cd0
2e975d9
7c69369
c0768ae
d592b46
32ffc6f
bbe5b53
e8e8e90
4866694
2b4c988
1ea7857
bb63493
c615bb6
072be2a
07b4bc8
344c0ee
60269c4
2c5d123
b66e684
c50c2c6
179db7b
d28516c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace BowlingBall.Tests | ||
{ | ||
public class FrameTest | ||
{ | ||
[Fact] | ||
public void RollValueMoreThan10() | ||
{ | ||
//roll cannot be more than 10 | ||
var result = Frame.IsValidRoll(12); | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void RollValueNegative() | ||
{ | ||
//roll cannot be less than 0 | ||
var result = Frame.IsValidRoll(-2); | ||
Assert.False(result); | ||
} | ||
[Fact] | ||
public void ValidRollValues() | ||
{ | ||
//valid roll values lies in the range of 0 to 10 | ||
var result1 = Frame.IsValidRoll(0); | ||
var result2 = Frame.IsValidRoll(10); | ||
var result3 = Frame.IsValidRoll(4); | ||
var result4 = Frame.IsValidRoll(2); | ||
var result5 = Frame.IsValidRoll(7); | ||
|
||
var result = result1 && result2 && result3 && result4 && result5; | ||
Assert.True(result); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
namespace BowlingBall.Tests | ||
{ | ||
public class GameTest | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These all tests should be in file GameFixture.cs |
||
[Fact] | ||
public void RollWithPinsMoreThan10() | ||
{ | ||
//roll cannot be more than 10 or negative | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create one private variable to hold instance of Game class and use that variable everywhere, rather than creating new game instance in every fixture |
||
try | ||
{ | ||
Game newGame = new Game(); | ||
newGame.Roll(11); | ||
} | ||
catch(Exception E) | ||
{ | ||
//throws Exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void RollWithPinsLessThan0() | ||
{ | ||
//roll cannot be more than 10 or negative | ||
try | ||
{ | ||
Game newGame = new Game(); | ||
newGame.Roll(-2); | ||
} | ||
catch (Exception E) | ||
{ | ||
//throws Exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void RollWithvalidPins() | ||
{ | ||
//roll cannot be more than 10 or negative | ||
try | ||
{ | ||
Game newGame = new Game(); | ||
newGame.Roll(2); | ||
} | ||
catch (Exception E) | ||
{ | ||
//should not throw exception | ||
Assert.True(false); | ||
} | ||
Assert.True(true); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using BowlingBall; | ||
using Xunit; | ||
namespace BowlingBall.Tests | ||
{ | ||
public class RegularFrameTest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename class as RegularFrameFixture |
||
{ | ||
[Fact] | ||
public void NegativeRollsToCreateRegularFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
RegularFrame regularFrame = new RegularFrame(-1, -2); | ||
} | ||
catch(Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void OneNegativeRollToCreateRegularFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
RegularFrame regularFrame = new RegularFrame(-1, 2); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void InvalidRollToCreateRegularFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
RegularFrame regularFrame = new RegularFrame(100,1); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void RollsSumUpToValueMoreThanExpectedToCreateRegularFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
RegularFrame regularFrame = new RegularFrame(5, 6); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void validRollsToCreateRegularFrame() | ||
{ | ||
//valid roll shall not throw exception | ||
try | ||
{ | ||
RegularFrame regularFrame = new RegularFrame(5, 4); | ||
} | ||
catch (Exception e) | ||
{ | ||
Assert.True(false); | ||
} | ||
Assert.True(true); | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
namespace BowlingBall.Tests | ||
{ | ||
public class SpareFrameTest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename class as SpareFrameFixture |
||
{ | ||
[Fact] | ||
public void NegativeRollsToCreateSpareFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(-1, -2,-8); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. var |
||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void FirstRollNegativeToCreateSpareFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(-1, 2, 8); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
|
||
[Fact] | ||
public void SecondRollNegativeToCreateSpareFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(1, -2, 8); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
|
||
[Fact] | ||
public void ThirdRollNegativeToCreateSpareFrame() | ||
{ | ||
//Negative roll shall throw exception | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(1, 2, -8); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void RollsSumUpToValueLessThanExpectedToCreateSpareFrame() | ||
{ | ||
//sum of rolls shall be 10 to create a spare frame | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(5,4,10); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void RollsSumUpToValueMoreThanExpectedToCreateSpareFrame() | ||
{ | ||
//sum of rolls shall be 10 to create a spare frame | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(5, 6, 10); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void InvalidFirstRollToCreateSpareFrame() | ||
{ | ||
//roll can't be more than 10 | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(50, 4, 1); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void InvalidSecondRollToCreateSpareFrame() | ||
{ | ||
//roll can't be more than 10 | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(5, 14, 1); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void InvalidThirdRollToCreateSpareFrame() | ||
{ | ||
//roll can't be more than 10 | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(5, 4, 11); | ||
} | ||
catch (Exception e) | ||
{ | ||
//Throws exception | ||
return; | ||
} | ||
Assert.True(false); | ||
} | ||
[Fact] | ||
public void ValidSetOfRollsToCreateSpareFrame() | ||
{ | ||
try | ||
{ | ||
SpareFrame spareFrame = new SpareFrame(5, 5, 1); | ||
} | ||
catch (Exception e) | ||
{ | ||
//No exception is expected | ||
Assert.True(false); | ||
} | ||
Assert.True(true); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File name should be FrameFixture.cs