Skip to content
Permalink
Browse files

make unit tests buildable and passing on .NET Core

  • Loading branch information
Stephen Jennings
Stephen Jennings committed Jun 16, 2017
1 parent 1d5009c commit 3e6d8b6a1e355aa46cc1b91734970dd3e637c1c7
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -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);
}

@@ -13,7 +13,7 @@ public class MiscellaneousFacts
[Fact]
public void EnsureNoAsyncVoidTests()
{
AssertNoAsyncVoidMethods(GetType().Assembly);
AssertNoAsyncVoidMethods(GetType().GetTypeInfo().Assembly);
}

static void AssertNoAsyncVoidMethods(Assembly assembly)

This file was deleted.

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
@@ -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
@@ -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"]);
}
}
}
}
@@ -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>
@@ -0,0 +1,4 @@
{
"beanstalk.hostname": "localhost",
"beanstalk.port": 11300
}

0 comments on commit 3e6d8b6

Please sign in to comment.
You can’t perform that action at this time.