Skip to content

Commit

Permalink
Refactored prototype code slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Ewan authored and Ewan committed Apr 15, 2016
1 parent 027843c commit d4ac6e8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
4 changes: 1 addition & 3 deletions E.Deezer.Tests/E.Deezer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\TestServerTests.cs" />
<Compile Include="Utils\TestService.cs" />
<Compile Include="Utils\TestServiceResponder.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand All @@ -87,9 +88,6 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Genre.All.txt.txt" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\GenreAll.txt" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions E.Deezer.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.54")]
[assembly: AssemblyFileVersion("1.0.0.54")]
[assembly: AssemblyVersion("1.0.0.57")]
[assembly: AssemblyFileVersion("1.0.0.57")]
11 changes: 5 additions & 6 deletions E.Deezer.Tests/SetupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public class SetupTests
[OneTimeSetUp]
public void OneTimeSetUp()
{
Console.WriteLine("Starting up test server...");

ts = new TestService(10024);

ts.RegisterEndpoint("genre", GenreTest);
ts.RegisterEndpoint("genre", TestServiceResponder.GenreAll);
ts.Start();

Assert.NotNull(ts);
Expand All @@ -27,13 +29,10 @@ public void OneTimeSetUp()
[OneTimeTearDown]
public void OneTimeTearDown()
{
Console.WriteLine("Stopping test server...");

ts.Stop();
ts = null;
}

private string GenreTest(System.Collections.Generic.Dictionary<string, string> queryString)
{
return Resources.GenreAll;
}
}
}
7 changes: 6 additions & 1 deletion E.Deezer.Tests/Utils/TestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public WebServer(Func<HttpListenerRequest, string> method, params string[] prefi

public void Run()
{
Console.WriteLine("Webserver starting...");

ThreadPool.QueueUserWorkItem((o) =>
{
Console.WriteLine("Webserver running...");
try
{
while (_listener.IsListening)
Expand Down Expand Up @@ -68,8 +69,12 @@ public void Run()

public void Stop()
{
Console.WriteLine("Webserver stopping...");

_listener.Stop();
_listener.Close();

Console.WriteLine("Webserver stopped.");
}
}
}
16 changes: 16 additions & 0 deletions E.Deezer.Tests/Utils/TestServiceResponder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;

using E.Deezer.Tests.Properties;

namespace E.Deezer.Tests.Utils
{
public static class TestServiceResponder
{
public static string GenreAll(Dictionary<string, string> queryString)
{
return Resources.GenreAll;
}

}
}

0 comments on commit d4ac6e8

Please sign in to comment.