Skip to content

Commit 8e0a34a

Browse files
committed
fixed issue #2 and unit tests; cleanup
1 parent 54d23f8 commit 8e0a34a

27 files changed

Lines changed: 463 additions & 407 deletions

.gitignore

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@
44
# User-specific files
55
*.suo
66
*.user
7+
*.userosscache
78
*.sln.docstates
89

10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
913
# Build results
1014
[Dd]ebug/
1115
[Dd]ebugPublic/
1216
[Rr]elease/
17+
[Rr]eleases/
1318
x64/
19+
x86/
1420
build/
1521
bld/
1622
[Bb]in/
1723
[Oo]bj/
1824

19-
# Roslyn cache directories
20-
*.ide/
25+
# Visual Studio 2015 cache/options directory
26+
.vs/
27+
# Uncomment if you have tasks that create the project's static files in wwwroot
28+
#wwwroot/
2129

2230
# MSTest test Results
2331
[Tt]est[Rr]esult*/
2432
[Bb]uild[Ll]og.*
2533

26-
#NUNIT
34+
# NUNIT
2735
*.VisualState.xml
2836
TestResult.xml
2937

@@ -32,6 +40,10 @@ TestResult.xml
3240
[Rr]eleasePS/
3341
dlldata.c
3442

43+
# DNX
44+
project.lock.json
45+
artifacts/
46+
3547
*_i.c
3648
*_p.c
3749
*_i.h
@@ -72,6 +84,7 @@ ipch/
7284
*.psess
7385
*.vsp
7486
*.vspx
87+
*.sap
7588

7689
# TFS 2012 Local Workspace
7790
$tf/
@@ -84,7 +97,7 @@ _ReSharper*/
8497
*.[Rr]e[Ss]harper
8598
*.DotSettings.user
8699

87-
# JustCode is a .NET coding addin-in
100+
# JustCode is a .NET coding add-in
88101
.JustCode
89102

90103
# TeamCity is a build add-in
@@ -96,6 +109,7 @@ _TeamCity*
96109
# NCrunch
97110
_NCrunch_*
98111
.*crunch*.local.xml
112+
nCrunchTemp_*
99113

100114
# MightyMoose
101115
*.mm.*
@@ -123,22 +137,19 @@ publish/
123137
# Publish Web Output
124138
*.[Pp]ublish.xml
125139
*.azurePubxml
126-
## TODO: Comment the next line if you want to checkin your
127-
## web deploy settings but do note that will include unencrypted
128-
## passwords
129-
#*.pubxml
130-
131-
# NuGet Packages Directory
132-
packages/*
133-
## TODO: If the tool you use requires repositories.config
134-
## uncomment the next line
135-
#!packages/repositories.config
136-
137-
# Enable "build/" folder in the NuGet Packages folder since
138-
# NuGet packages use it for MSBuild targets.
139-
# This line needs to be after the ignore of the build folder
140-
# (and the packages folder if the line above has been uncommented)
141-
!packages/build/
140+
# TODO: Comment the next line if you want to checkin your web deploy settings
141+
# but database connection strings (with potential passwords) will be unencrypted
142+
*.pubxml
143+
*.publishproj
144+
145+
# NuGet Packages
146+
*.nupkg
147+
# The packages folder can be ignored because of Package Restore
148+
**/packages/*
149+
# except build/, which is used as an MSBuild target.
150+
!**/packages/build/
151+
# Uncomment if necessary however generally it will be regenerated when needed
152+
#!**/packages/repositories.config
142153

143154
# Windows Azure Build Output
144155
csx/
@@ -147,9 +158,13 @@ csx/
147158
# Windows Store app package directory
148159
AppPackages/
149160

161+
# Visual Studio cache files
162+
# files ending in .cache can be ignored
163+
*.[Cc]ache
164+
# but keep track of directories ending in .cache
165+
!*.[Cc]ache/
166+
150167
# Others
151-
sql/
152-
*.Cache
153168
ClientBin/
154169
[Ss]tyle[Cc]op.*
155170
~$*
@@ -159,7 +174,7 @@ ClientBin/
159174
*.pfx
160175
*.publishsettings
161176
node_modules/
162-
bower_components/
177+
orleans.codegen.cs
163178

164179
# RIA/Silverlight projects
165180
Generated_Code/
@@ -184,7 +199,20 @@ UpgradeLog*.htm
184199
# Microsoft Fakes
185200
FakesAssemblies/
186201

187-
# LightSwitch generated files
188-
GeneratedArtifacts/
189-
_Pvt_Extensions/
190-
ModelManifest.xml
202+
# Node.js Tools for Visual Studio
203+
.ntvs_analysis.dat
204+
205+
# Visual Studio 6 build log
206+
*.plg
207+
208+
# Visual Studio 6 workspace options file
209+
*.opt
210+
211+
# Visual Studio LightSwitch build output
212+
**/*.HTMLClient/GeneratedArtifacts
213+
**/*.DesktopClient/GeneratedArtifacts
214+
**/*.DesktopClient/ModelManifest.xml
215+
**/*.Server/GeneratedArtifacts
216+
**/*.Server/ModelManifest.xml
217+
_Pvt_Extensions
218+

Common/BindableBase.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,5 @@ protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
7272
{
7373
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
7474
}
75-
76-
/// <summary>
77-
/// Notifies listeners that a property value has changed.
78-
/// </summary>
79-
/// <param name="expression">Lambda expression that identifies the property used to notify listeners.</param>
80-
protected void OnPropertyChanged<TProperty>(Expression<Func<TProperty>> expression)
81-
{
82-
this.PropertyChanged(this, new PropertyChangedEventArgs((expression.Body as MemberExpression).Member.Name));
83-
}
8475
}
8576
}

Model/Game.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,29 @@ public Game(List<Question> questions)
4747

4848
public void AddPlayer(string playerName)
4949
{
50-
if (this.PlayerNames.Contains(playerName)) playerName += ".";
51-
this.PlayerNames.Add(playerName);
50+
if (this.PlayerNames.Contains(playerName)) playerName += ".";
51+
this.PlayerNames.Add(playerName);
5252
this.SubmittedAnswers.Add(playerName,
5353
new Dictionary<Question, int?>(this.Questions.Count));
54-
this.OnPropertyChanged(() => this.PlayerNames);
55-
this.OnPropertyChanged(() => this.SubmittedAnswers);
54+
this.OnPropertyChanged(nameof(PlayerNames));
55+
this.OnPropertyChanged(nameof(SubmittedAnswers));
5656
}
5757

5858
public void RemovePlayer(string playerName)
5959
{
6060
if (this.PlayerNames.Remove(playerName))
6161
{
6262
this.SubmittedAnswers.Remove(playerName);
63-
this.OnPropertyChanged(() => this.PlayerNames);
64-
this.OnPropertyChanged(() => this.SubmittedAnswers);
63+
this.OnPropertyChanged(nameof(PlayerNames));
64+
this.OnPropertyChanged(nameof(SubmittedAnswers));
6565
}
6666
}
6767

6868
public bool SubmitAnswer(string playerName, int answerIndex)
6969
{
7070
if (playerName == null || this.CurrentQuestion == null) return false;
7171
this.SubmittedAnswers[playerName][this.CurrentQuestion] = answerIndex;
72-
this.OnPropertyChanged(() => this.SubmittedAnswers);
72+
this.OnPropertyChanged(nameof(SubmittedAnswers));
7373
return true;
7474
}
7575

@@ -91,9 +91,9 @@ private void SendCurrentQuestion()
9191
// when the current question goes to null so it can update its UI state.
9292
this.NewQuestionAvailable(this, new QuestionEventArgs { Question = this.CurrentQuestion });
9393

94-
this.OnPropertyChanged(() => this.CurrentQuestion);
95-
this.OnPropertyChanged(() => this.IsGameOver);
96-
this.OnPropertyChanged(() => this.Winner);
94+
this.OnPropertyChanged(nameof(CurrentQuestion));
95+
this.OnPropertyChanged(nameof(IsGameOver));
96+
this.OnPropertyChanged(nameof(Winner));
9797
}
9898

9999
public Dictionary<string, int> GetResults()

Model/MockHostCommunicator.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,27 @@ namespace QuizGame.Model
3131
public class MockHostCommunicator : IHostCommunicator
3232
{
3333
internal MockClientCommunicator Client1 { get; set; }
34-
internal MockClientCommunicator Client2 { get; set; }
34+
internal MockClientCommunicator Client2 { get; set; }
3535

3636
private List<string> clientList = new List<string>();
3737

3838
public async Task EnterLobby()
3939
{
4040
// Simulate a periodic broadcast. Loops until the ClientViewModel adds a handler to the GameAvailable event.
41-
while (!this.Client1.OnGameAvailable() || !this.Client2.OnGameAvailable()) { await Task.Delay(100); }
41+
while (!this.Client1.OnGameAvailable() || !this.Client2.OnGameAvailable()) { await Task.Delay(100); }
4242
}
4343

4444
public void LeaveLobby()
4545
{
4646
// No need to do anything in the mock version.
4747
}
4848

49-
public async Task SendQuestion(Question question)
49+
public Task SendQuestion(Question question)
5050
{
5151
this.Client1.OnNewQuestionAvailable(question);
52-
this.Client2.OnNewQuestionAvailable(question);
53-
}
52+
this.Client2.OnNewQuestionAvailable(question);
53+
return Task.CompletedTask;
54+
}
5455

5556
public event EventHandler<PlayerEventArgs> PlayerJoined = delegate { };
5657

P2PHelper/Properties/P2PHelper.rd.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
2828
<Library Name="P2PHelper">
2929

30-
<!-- add directives for your library here -->
30+
<!-- add directives for your library here -->
3131

3232
</Library>
3333
</Directives>

QuizGame.sln

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22823.1
4+
VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuizGameHost", "QuizGameHost\QuizGameHost.csproj", "{05D4E5FD-14DB-4982-9DCC-7AD10D11D0A7}"
77
EndProject
@@ -18,7 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1818
README.md = README.md
1919
EndProjectSection
2020
EndProject
21-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuizGameTests", "QuizGameTests\QuizGameTests.csproj", "{D5687D50-F68B-4BF3-AABB-CC7349E98552}"
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuizGameTests", "QuizGameTests\QuizGameTests.csproj", "{0DCE564F-5636-43C9-A655-5600EFBFB5E9}"
2222
EndProject
2323
Global
2424
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -78,24 +78,24 @@ Global
7878
{737229AE-D189-4765-B37B-31A326996A70}.Release|x64.Build.0 = Release|x64
7979
{737229AE-D189-4765-B37B-31A326996A70}.Release|x86.ActiveCfg = Release|x86
8080
{737229AE-D189-4765-B37B-31A326996A70}.Release|x86.Build.0 = Release|x86
81-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|ARM.ActiveCfg = Debug|ARM
82-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|ARM.Build.0 = Debug|ARM
83-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|ARM.Deploy.0 = Debug|ARM
84-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|x64.ActiveCfg = Debug|x64
85-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|x64.Build.0 = Debug|x64
86-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|x64.Deploy.0 = Debug|x64
87-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|x86.ActiveCfg = Debug|x86
88-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|x86.Build.0 = Debug|x86
89-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Debug|x86.Deploy.0 = Debug|x86
90-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|ARM.ActiveCfg = Release|ARM
91-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|ARM.Build.0 = Release|ARM
92-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|ARM.Deploy.0 = Release|ARM
93-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|x64.ActiveCfg = Release|x64
94-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|x64.Build.0 = Release|x64
95-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|x64.Deploy.0 = Release|x64
96-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|x86.ActiveCfg = Release|x86
97-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|x86.Build.0 = Release|x86
98-
{D5687D50-F68B-4BF3-AABB-CC7349E98552}.Release|x86.Deploy.0 = Release|x86
81+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|ARM.ActiveCfg = Debug|ARM
82+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|ARM.Build.0 = Debug|ARM
83+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|ARM.Deploy.0 = Debug|ARM
84+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|x64.ActiveCfg = Debug|x64
85+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|x64.Build.0 = Debug|x64
86+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|x64.Deploy.0 = Debug|x64
87+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|x86.ActiveCfg = Debug|x86
88+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|x86.Build.0 = Debug|x86
89+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Debug|x86.Deploy.0 = Debug|x86
90+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|ARM.ActiveCfg = Release|ARM
91+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|ARM.Build.0 = Release|ARM
92+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|ARM.Deploy.0 = Release|ARM
93+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|x64.ActiveCfg = Release|x64
94+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|x64.Build.0 = Release|x64
95+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|x64.Deploy.0 = Release|x64
96+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|x86.ActiveCfg = Release|x86
97+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|x86.Build.0 = Release|x86
98+
{0DCE564F-5636-43C9-A655-5600EFBFB5E9}.Release|x86.Deploy.0 = Release|x86
9999
EndGlobalSection
100100
GlobalSection(SolutionProperties) = preSolution
101101
HideSolutionNode = FALSE

QuizGameClient/App.xaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ THE SOFTWARE.
2929
xmlns:local="using:QuizGameClient"
3030
xmlns:viewmodel="using:QuizGame.ViewModel">
3131

32-
<Application.Resources>
33-
<viewmodel:ViewModelLocator x:Key="Locator"/>
34-
<x:Int32 x:Key="PivotHeaderItemCharacterSpacing">-25</x:Int32>
35-
<Style x:Key="SubtitleTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextBlockStyle}">
36-
<Setter Property="FontWeight" Value="Normal"/>
37-
</Style>
38-
<Style TargetType="Button">
39-
<Setter Property="Margin" Value="12"/>
40-
</Style>
41-
</Application.Resources>
32+
<Application.Resources>
33+
<x:Int32 x:Key="PivotHeaderItemCharacterSpacing">-25</x:Int32>
34+
<Style x:Key="SubtitleTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextBlockStyle}">
35+
<Setter Property="FontWeight" Value="Normal"/>
36+
</Style>
37+
<Style TargetType="Button">
38+
<Setter Property="Margin" Value="12"/>
39+
</Style>
40+
</Application.Resources>
4241

4342
</Application>

QuizGameClient/App.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
using Windows.UI.Xaml.Media;
4040
using Windows.UI.Xaml.Navigation;
4141

42-
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409
43-
4442
namespace QuizGameClient
4543
{
4644
/// <summary>

QuizGameClient/MainPage.xaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ THE SOFTWARE.
2929
xmlns:View="using:QuizGame.View"
3030
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
3131
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
32-
mc:Ignorable="d"
33-
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
32+
mc:Ignorable="d">
3433

35-
<View:ClientView/>
34+
<View:ClientView x:Name="ClientView"/>
3635

3736
</Page>

0 commit comments

Comments
 (0)