Skip to content
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

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0097741
Implemented the Game class
tavisca-dmandal Jul 4, 2019
1c7085f
Created a TheBowlingGame class for each instance of the bowling game
tavisca-dmandal Jul 4, 2019
e9fbeae
Created a TheBowlingGame class for each instance of bowling game
tavisca-dmandal Jul 4, 2019
daa719b
Created Frame class for storing data of each frame
tavisca-dmandal Jul 4, 2019
aac69f7
Implemented different types of frames which inherits from Frame class
tavisca-dmandal Jul 4, 2019
096f89b
Removed all syntax errors by importing required libraries and specify…
tavisca-dmandal Jul 4, 2019
742283f
Added code to check validity of a roll
tavisca-dmandal Jul 4, 2019
4dec522
Added code to check rolls before creating a frame
tavisca-dmandal Jul 4, 2019
1848520
First Test
tavisca-dmandal Jul 4, 2019
c3ce58a
Tests to ckeck is invalid rolls throws exception
tavisca-dmandal Jul 4, 2019
f88b64a
Added tests to check Frame class
tavisca-dmandal Jul 4, 2019
f5a7cd0
Added a test to crate valid frame in RegularFrame
tavisca-dmandal Jul 4, 2019
2e975d9
Removed errors and thus it passed all tests successfully
tavisca-dmandal Jul 4, 2019
7c69369
Created Tests for SpareTest Class (All the tests failed except last one)
tavisca-dmandal Jul 4, 2019
c0768ae
Rectified the wrong test case
tavisca-dmandal Jul 4, 2019
d592b46
Edited the code to valid one ....hence all test cases got passed
tavisca-dmandal Jul 4, 2019
32ffc6f
Added tests to test StrikeFrame class
tavisca-dmandal Jul 4, 2019
bbe5b53
Added code to check rolls before creating strike frame
tavisca-dmandal Jul 4, 2019
e8e8e90
Created GameTest file and added tests to check roll method of game class
tavisca-dmandal Jul 4, 2019
4866694
removed a small bug from GameTest class
tavisca-dmandal Jul 4, 2019
2b4c988
Implemented tests to check how exceptions are handled by TheBowlingGa…
tavisca-dmandal Jul 4, 2019
1ea7857
Added tests for the main function in TheBowlingGame Class
tavisca-dmandal Jul 4, 2019
bb63493
Implemented Game class to pass all test cases
tavisca-dmandal Jul 4, 2019
c615bb6
Updated TheBowlingGame class to check and store frames
tavisca-dmandal Jul 4, 2019
072be2a
Added logic for extra roll in frame 10 for strike and spare
tavisca-dmandal Jul 4, 2019
07b4bc8
Renamed the file from FrameTest to FrameFixture
tavisca-dmandal Jul 8, 2019
344c0ee
Renamed the file GameTest to GameFixture and added a private varable…
tavisca-dmandal Jul 8, 2019
60269c4
Renamed the file RegularFrameTest to RegularFrameFixture and created …
tavisca-dmandal Jul 8, 2019
2c5d123
Renamed the file SpareFrameTest to SpareFrameFixture and used var for…
tavisca-dmandal Jul 8, 2019
b66e684
Renamed file to StrikeFrameFixture and used var for local variable de…
tavisca-dmandal Jul 8, 2019
c50c2c6
Renmed the file to BowlingGameFixture nd used var for local variable …
tavisca-dmandal Jul 8, 2019
179db7b
Removed "The" from the name of the file as well as the class
tavisca-dmandal Jul 8, 2019
d28516c
Made a simple change as the name of the classes changed
tavisca-dmandal Jul 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions BowlingBall.Tests/FrameTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;

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

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);
}
}
}
2 changes: 1 addition & 1 deletion BowlingBall.Tests/GameFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class GameFixture
[Fact]
public void DummyTest()
{
// This is a dummy test that will always pass.
Assert.True(true);
}
}
}
58 changes: 58 additions & 0 deletions BowlingBall.Tests/GameTest.cs
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
{

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The 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);
}
}
}
86 changes: 86 additions & 0 deletions BowlingBall.Tests/RegularFrameTest.cs
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

Choose a reason for hiding this comment

The 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);
}

}
}
161 changes: 161 additions & 0 deletions BowlingBall.Tests/SpareFrameTest.cs
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

Choose a reason for hiding this comment

The 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);

Choose a reason for hiding this comment

The 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);
}
}
}
Loading