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)
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Turbocharged.Beanstalk.Tests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Turbocharged.Beanstalk.Tests")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("348bb9e1-a1cc-4cf7-9a1f-0353d56b4186")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// 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.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -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.