From aed5b9a1c99c9a04fbb97adc8b4636e8fe41d6d3 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Tue, 25 Mar 2014 15:42:50 -0700 Subject: [PATCH] Convert tests to K test. --- .../AuthenticationTests.cs | 1 - .../HttpsTests.cs | 13 ++++------- .../RequestTests.cs | 1 - .../ResponseSendFileTests.cs | 15 ++++++++---- .../Utilities.cs | 3 +++ .../project.json | 23 ++++++++++++------- 6 files changed, 33 insertions(+), 23 deletions(-) diff --git a/test/Microsoft.AspNet.Server.WebListener.Test/AuthenticationTests.cs b/test/Microsoft.AspNet.Server.WebListener.Test/AuthenticationTests.cs index 24a3587f15..9f8887a5c8 100644 --- a/test/Microsoft.AspNet.Server.WebListener.Test/AuthenticationTests.cs +++ b/test/Microsoft.AspNet.Server.WebListener.Test/AuthenticationTests.cs @@ -12,7 +12,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.FeatureModel; using Microsoft.AspNet.PipelineCore; using Xunit; -using Xunit.Extensions; namespace Microsoft.AspNet.Server.WebListener.Test { diff --git a/test/Microsoft.AspNet.Server.WebListener.Test/HttpsTests.cs b/test/Microsoft.AspNet.Server.WebListener.Test/HttpsTests.cs index f29b417a1b..d96effc06c 100644 --- a/test/Microsoft.AspNet.Server.WebListener.Test/HttpsTests.cs +++ b/test/Microsoft.AspNet.Server.WebListener.Test/HttpsTests.cs @@ -5,7 +5,6 @@ // ----------------------------------------------------------------------- using System; -using System.Collections.Generic; using System.IO; using System.Net.Http; using System.Security.Cryptography.X509Certificates; @@ -18,13 +17,11 @@ using Xunit; namespace Microsoft.AspNet.Server.WebListener.Test { - using AppFunc = Func; - public class HttpsTests { private const string Address = "https://localhost:9090/"; - [Fact] + [Fact(Skip = "TODO: Add trait filtering support so these SSL tests don't get run on teamcity or the command line."), Trait("scheme", "https")] public async Task Https_200OK_Success() { using (Utilities.CreateHttpsServer(env => @@ -37,7 +34,7 @@ namespace Microsoft.AspNet.Server.WebListener.Test } } - [Fact] + [Fact(Skip = "TODO: Add trait filtering support so these SSL tests don't get run on teamcity or the command line."), Trait("scheme", "https")] public async Task Https_SendHelloWorld_Success() { using (Utilities.CreateHttpsServer(env => @@ -53,7 +50,7 @@ namespace Microsoft.AspNet.Server.WebListener.Test } } - [Fact] + [Fact(Skip = "TODO: Add trait filtering support so these SSL tests don't get run on teamcity or the command line."), Trait("scheme", "https")] public async Task Https_EchoHelloWorld_Success() { using (Utilities.CreateHttpsServer(env => @@ -72,7 +69,7 @@ namespace Microsoft.AspNet.Server.WebListener.Test } } - [Fact] + [Fact(Skip = "TODO: Add trait filtering support so these SSL tests don't get run on teamcity or the command line."), Trait("scheme", "https")] public async Task Https_ClientCertNotSent_ClientCertNotPresent() { using (Utilities.CreateHttpsServer(async env => @@ -89,7 +86,7 @@ namespace Microsoft.AspNet.Server.WebListener.Test } } - [Fact] + [Fact(Skip = "TODO: Add trait filtering support so these SSL tests don't get run on teamcity or the command line."), Trait("scheme", "https")] public async Task Https_ClientCertRequested_ClientCertPresent() { using (Utilities.CreateHttpsServer(async env => diff --git a/test/Microsoft.AspNet.Server.WebListener.Test/RequestTests.cs b/test/Microsoft.AspNet.Server.WebListener.Test/RequestTests.cs index c95292bbcf..dcfa78eab3 100644 --- a/test/Microsoft.AspNet.Server.WebListener.Test/RequestTests.cs +++ b/test/Microsoft.AspNet.Server.WebListener.Test/RequestTests.cs @@ -16,7 +16,6 @@ using Microsoft.AspNet.Hosting.Server; using Microsoft.AspNet.HttpFeature; using Microsoft.AspNet.PipelineCore; using Xunit; -using Xunit.Extensions; namespace Microsoft.AspNet.Server.WebListener.Test { diff --git a/test/Microsoft.AspNet.Server.WebListener.Test/ResponseSendFileTests.cs b/test/Microsoft.AspNet.Server.WebListener.Test/ResponseSendFileTests.cs index 21ec5eb331..19d790fffa 100644 --- a/test/Microsoft.AspNet.Server.WebListener.Test/ResponseSendFileTests.cs +++ b/test/Microsoft.AspNet.Server.WebListener.Test/ResponseSendFileTests.cs @@ -20,15 +20,20 @@ using Xunit; namespace Microsoft.AspNet.Server.WebListener.Test { - using AppFunc = Func; - public class ResponseSendFileTests { private const string Address = "http://localhost:8080/"; - private static readonly string AbsoluteFilePath = Environment.CurrentDirectory + "\\Microsoft.AspNet.Server.WebListener.dll"; - private static readonly string RelativeFilePath = "Microsoft.AspNet.Server.WebListener.dll"; - private static readonly long FileLength = new FileInfo(AbsoluteFilePath).Length; + private readonly string AbsoluteFilePath; + private readonly string RelativeFilePath; + private readonly long FileLength; + public ResponseSendFileTests() + { + AbsoluteFilePath = Directory.GetFiles(Environment.CurrentDirectory).First(); + RelativeFilePath = Path.GetFileName(AbsoluteFilePath); + FileLength = new FileInfo(AbsoluteFilePath).Length; + } + [Fact] public async Task ResponseSendFile_SupportKeys_Present() { diff --git a/test/Microsoft.AspNet.Server.WebListener.Test/Utilities.cs b/test/Microsoft.AspNet.Server.WebListener.Test/Utilities.cs index eba2edfd9e..adacfdf832 100644 --- a/test/Microsoft.AspNet.Server.WebListener.Test/Utilities.cs +++ b/test/Microsoft.AspNet.Server.WebListener.Test/Utilities.cs @@ -4,6 +4,9 @@ using System.Threading.Tasks; using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.Hosting.Server; +// These tests can't run in parallel because they all use the same port. +[assembly: Xunit.CollectionBehaviorAttribute(Xunit.CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)] + namespace Microsoft.AspNet.Server.WebListener.Test { using AppFunc = Func; diff --git a/test/Microsoft.AspNet.Server.WebListener.Test/project.json b/test/Microsoft.AspNet.Server.WebListener.Test/project.json index a2837ddee9..76202da8df 100644 --- a/test/Microsoft.AspNet.Server.WebListener.Test/project.json +++ b/test/Microsoft.AspNet.Server.WebListener.Test/project.json @@ -1,6 +1,14 @@ { "version" : "0.1-alpha-*", + "commands": { + "test": "Xunit.KRunner" + }, "dependencies": { + "Xunit.KRunner": "0.1-alpha-*", + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*", "Microsoft.AspNet.Server.WebListener" : "", "Microsoft.AspNet.Abstractions" : "0.1-alpha-*", "Microsoft.AspNet.ConfigurationModel": "0.1-alpha-*", @@ -11,13 +19,12 @@ "Microsoft.AspNet.Hosting": "0.1-alpha-*" }, "configurations": { - "net45": { - "dependencies": { - "XUnit": "1.9.2", - "XUnit.Extensions": "1.9.2", - "System.Net.Http": "", - "System.Net.Http.WebRequest": "" - } - } + "net45": { + "dependencies": { + "System.Runtime": "", + "System.Net.Http": "", + "System.Net.Http.WebRequest": "" + } + } } }