Skip to content

Commit 6b6a568

Browse files
committed
commit auf git
0 parents  commit 6b6a568

File tree

117 files changed

+14953
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+14953
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.hg
2+
.hgignore
3+
*.user
4+
*.obj
5+
*.lib
6+
*.suo
7+
*.ncb
8+
*.cache
9+
*.orig
10+
*.sdf
11+
[Oo]bj
12+
[Bb]in
13+
[Bb]uild
14+
[Db]ebug
15+
[Rr]elease
16+
_ReSharper*/

CodingDojoTennis/CodingDojoTennis.sln

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingDojoTennis", "CodingDojoTennis\CodingDojoTennis.csproj", "{C521BD0F-3629-4E31-B778-4E62CCD4C23E}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{C521BD0F-3629-4E31-B778-4E62CCD4C23E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{C521BD0F-3629-4E31-B778-4E62CCD4C23E}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{C521BD0F-3629-4E31-B778-4E62CCD4C23E}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{C521BD0F-3629-4E31-B778-4E62CCD4C23E}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{C521BD0F-3629-4E31-B778-4E62CCD4C23E}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>CodingDojoTennis</RootNamespace>
12+
<AssemblyName>CodingDojoTennis</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="nunit.framework">
35+
<HintPath>..\packages\NUnit.2.5.7.10213\lib\nunit.framework.dll</HintPath>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Game.cs" />
47+
<Compile Include="GameTests.cs" />
48+
<Compile Include="Player.cs" />
49+
<Compile Include="PlayerTests.cs" />
50+
<Compile Include="Properties\AssemblyInfo.cs" />
51+
<Compile Include="Score.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="packages.config" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
58+
Other similar extension points exist, see Microsoft.Common.targets.
59+
<Target Name="BeforeBuild">
60+
</Target>
61+
<Target Name="AfterBuild">
62+
</Target>
63+
-->
64+
</Project>
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
3+
namespace CodingDojoTennis
4+
{
5+
public class Game
6+
{
7+
private bool isOver;
8+
9+
public Game()
10+
{
11+
PlayerOne = new Player();
12+
PlayerTwo = new Player();
13+
}
14+
15+
public Player PlayerTwo { get; private set; }
16+
17+
public Player PlayerOne { get; private set; }
18+
19+
20+
public bool IsOver
21+
{
22+
get
23+
{
24+
if (PlayerOne.Score == Score.Game){
25+
return true;
26+
}
27+
if (PlayerTwo.Score == Score.Game){
28+
return true;
29+
}
30+
return false;
31+
}
32+
}
33+
34+
private void ScorePlayerAgainst(Player player, Player playerAgainst)
35+
{
36+
player.Scored();
37+
38+
if (player.Score == Score.Advantage && playerAgainst.Score == Score.Advantage)
39+
{
40+
player.Score = Score.Forty;
41+
playerAgainst.Score = Score.Forty;
42+
}
43+
else if (player.Score == Score.Advantage && playerAgainst.Score < Score.Forty){
44+
player.Score = Score.Game;
45+
}
46+
}
47+
48+
public void ScorePlayerOne()
49+
{
50+
ScorePlayerAgainst(PlayerOne, PlayerTwo);
51+
}
52+
53+
public void ScorePlayerTwo()
54+
{
55+
ScorePlayerAgainst(PlayerTwo, PlayerOne);
56+
}
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
using NUnit.Framework;
2+
3+
namespace CodingDojoTennis
4+
{
5+
[TestFixture]
6+
public class GameTests
7+
{
8+
[Test]
9+
public void New_Game_Should_Score_equals_0_0()
10+
{
11+
var game = new Game();
12+
Assert.AreEqual(Score.Love, game.PlayerOne.Score);
13+
Assert.AreEqual(Score.Love, game.PlayerTwo.Score);
14+
}
15+
16+
[Test]
17+
public void When_Score_is_0_0_then_game_is_not_over()
18+
{
19+
var game = new Game();
20+
Assert.IsFalse(game.IsOver);
21+
}
22+
23+
[Test]
24+
public void When_Score_is_40_0_and_Player1_scores_then_game_end()
25+
{
26+
var game = new Game();
27+
game.PlayerOne.Score = Score.Forty;
28+
game.PlayerTwo.Score = Score.Love;
29+
game.ScorePlayerOne();
30+
Assert.IsTrue(game.IsOver);
31+
}
32+
33+
[Test]
34+
public void When_Score_is_0_40_and_Player2_scores_then_game_end()
35+
{
36+
var game = new Game();
37+
game.PlayerOne.Score = Score.Love;
38+
game.PlayerTwo.Score = Score.Forty;
39+
game.ScorePlayerTwo();
40+
Assert.IsTrue(game.IsOver);
41+
}
42+
43+
[Test]
44+
public void When_Score_is_40_30_and_Player1_scores_then_game_end()
45+
{
46+
var game = new Game();
47+
game.PlayerOne.Score = Score.Forty;
48+
game.PlayerTwo.Score = Score.Thirty;
49+
game.ScorePlayerOne();
50+
Assert.IsTrue(game.IsOver);
51+
}
52+
53+
54+
[Test]
55+
public void When_Score_is_40_40_and_Player1_scores_then_game_not_ended()
56+
{
57+
var game = new Game();
58+
DeuceGame(game);
59+
game.ScorePlayerOne();
60+
Assert.IsFalse(game.IsOver);
61+
}
62+
63+
private void DeuceGame(Game game)
64+
{
65+
game.PlayerOne.Score = Score.Forty;
66+
game.PlayerTwo.Score = Score.Forty;
67+
}
68+
69+
[Test]
70+
public void When_Score_is_40_40_and_Player1_scores_then_Player1_Score_is_45()
71+
{
72+
var game = new Game();
73+
DeuceGame(game);
74+
game.ScorePlayerOne();
75+
Assert.AreEqual(Score.Advantage, game.PlayerOne.Score);
76+
}
77+
78+
[Test]
79+
public void When_Score_is_40_40_and_Player2_scores_then_Player2_Score_is_45()
80+
{
81+
var game = new Game();
82+
DeuceGame(game);
83+
game.ScorePlayerTwo();
84+
Assert.AreEqual(Score.Advantage, game.PlayerTwo.Score);
85+
}
86+
87+
88+
[Test]
89+
public void When_Score_is_40_40_and_Player1_scores_two_times_then_game_ends()
90+
{
91+
var game = new Game();
92+
DeuceGame(game);
93+
game.ScorePlayerOne();
94+
game.ScorePlayerOne();
95+
Assert.IsTrue(game.IsOver);
96+
}
97+
98+
[Test]
99+
public void When_Score_is_40_40_and_Player2_scores_two_times_then_game_ends()
100+
{
101+
var game = new Game();
102+
DeuceGame(game);
103+
game.ScorePlayerTwo();
104+
game.ScorePlayerTwo();
105+
Assert.IsTrue(game.IsOver);
106+
}
107+
108+
109+
[Test]
110+
public void When_Player1_has_Advantage_and_Player2_scores_then_score_is_not_ended()
111+
{
112+
var game = new Game();
113+
DeuceGame(game);
114+
game.ScorePlayerOne();
115+
game.ScorePlayerTwo();
116+
Assert.IsFalse(game.IsOver);
117+
}
118+
119+
[Test]
120+
public void When_Player1_has_Advantage_and_Player2_scores_then_score_is_40_40()
121+
{
122+
var game = new Game();
123+
DeuceGame(game);
124+
game.ScorePlayerOne();
125+
game.ScorePlayerTwo();
126+
Assert.AreEqual(Score.Forty, game.PlayerOne.Score);
127+
Assert.AreEqual(Score.Forty, game.PlayerTwo.Score);
128+
}
129+
}
130+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace CodingDojoTennis
2+
{
3+
public class Player
4+
{
5+
public Score Score { get; set; }
6+
7+
public void Scored()
8+
{
9+
Score++;
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NUnit.Framework;
2+
3+
namespace CodingDojoTennis
4+
{
5+
[TestFixture]
6+
public class PlayerTests
7+
{
8+
[Test]
9+
public void New_Player_Score_Should_Love()
10+
{
11+
var player = new Player();
12+
Assert.AreEqual(Score.Love,player.Score);
13+
}
14+
15+
[Test]
16+
public void With_new_Player_and_Scored_Score_Should_Fifteen()
17+
{
18+
var player = new Player();
19+
player.Scored();
20+
Assert.AreEqual(Score.Fifteen, player.Score);
21+
}
22+
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CodingDojoTennis")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("http://der-albert.com")]
12+
[assembly: AssemblyProduct("CodingDojoTennis")]
13+
[assembly: AssemblyCopyright("Copyright © http://der-albert.com 2010")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("680804d6-f950-49bd-874f-df967c173114")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace CodingDojoTennis
2+
{
3+
public enum Score
4+
{
5+
Love,
6+
Fifteen,
7+
Thirty,
8+
Forty,
9+
Advantage,
10+
Game
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit" version="2.5.7.10213" />
4+
</packages>

0 commit comments

Comments
 (0)