Skip to content

Commit

Permalink
make unit tests buildable and passing on .NET Core
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Jennings committed Jun 16, 2017
1 parent 1d5009c commit 3e6d8b6
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 44 deletions.
5 changes: 2 additions & 3 deletions src/Turbocharged.Beanstalk.Tests/ConnectionFacts.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
Expand All @@ -24,8 +23,8 @@ public class ConnectionFacts : IDisposable

public ConnectionFacts()
{
hostname = Environment.GetEnvironmentVariable("BEANSTALK_HOSTNAME") ?? ConfigurationManager.AppSettings["Hostname"];
port = Convert.ToInt32(Environment.GetEnvironmentVariable("BEANSTALK_PORT") ?? ConfigurationManager.AppSettings["Port"]);
hostname = Settings.BeanstalkHostName;
port = Settings.BeanstalkPort;
connectionString = string.Format("{0}:{1}", hostname, port);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Turbocharged.Beanstalk.Tests/MiscellaneousFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MiscellaneousFacts
[Fact]
public void EnsureNoAsyncVoidTests()
{
AssertNoAsyncVoidMethods(GetType().Assembly);
AssertNoAsyncVoidMethods(GetType().GetTypeInfo().Assembly);
}

static void AssertNoAsyncVoidMethods(Assembly assembly)
Expand Down
36 changes: 0 additions & 36 deletions src/Turbocharged.Beanstalk.Tests/Properties/AssemblyInfo.cs

This file was deleted.

5 changes: 2 additions & 3 deletions src/Turbocharged.Beanstalk.Tests/SerializationFacts.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
Expand All @@ -26,8 +25,8 @@ public class SerializationFacts : IDisposable

public SerializationFacts()
{
hostname = Environment.GetEnvironmentVariable("BEANSTALK_HOSTNAME") ?? ConfigurationManager.AppSettings["Hostname"];
port = Convert.ToInt32(Environment.GetEnvironmentVariable("BEANSTALK_PORT") ?? ConfigurationManager.AppSettings["Port"]);
hostname = Settings.BeanstalkHostName;
port = Settings.BeanstalkPort;
connectionString = string.Format("{0}:{1}", hostname, port);
options = new WorkerOptions { Tubes = { "jobjects" } };
config = new ConnectionConfiguration
Expand Down
33 changes: 33 additions & 0 deletions src/Turbocharged.Beanstalk.Tests/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.Extensions.Configuration;
using System;
using System.IO;

namespace Turbocharged.Beanstalk.Tests
{
public static class Settings
{
static IConfigurationRoot Configuration { get; } =
new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("settings.json")
.Build();

public static string BeanstalkHostName
{
get
{
var fromEnv = Environment.GetEnvironmentVariable("BEANSTALK_HOSTNAME");
return fromEnv ?? Configuration["beanstalk.hostname"];
}
}

public static int BeanstalkPort
{
get
{
var fromEnv = Environment.GetEnvironmentVariable("BEANSTALK_PORT");
return int.Parse(fromEnv ?? Configuration["beanstalk.port"]);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Turbocharged.Beanstalk\Turbocharged.Beanstalk.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="settings.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/Turbocharged.Beanstalk.Tests/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"beanstalk.hostname": "localhost",
"beanstalk.port": 11300
}

0 comments on commit 3e6d8b6

Please sign in to comment.