diff --git a/.gitignore b/.gitignore index 5b85ade..9d62ca3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,227 @@ -/_ReSharper.uhttpsharp/ -/*.6.0.ReSharper.user -/*.suo -/packages/* -*/bin/* -*/obj/* +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +*.vs/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler *.psess *.vsp -*.nupkg \ No newline at end of file +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +*.pubxml +*.publishproj + +# NuGet Packages Directory +packages/* +*.nupkg + +## TODO: If the tool you use requires repositories.config +## uncomment the next line +#!packages/repositories.config + +# Enable "build/" folder in the NuGet Packages folder since +# NuGet packages use it for MSBuild targets. +# This line needs to be after the ignore of the build folder +# (and the packages folder if the line above has been uncommented) +!packages/build/ + +# PVC Build packages (https://github.com/pvcbuild/pvc) +pvc-packages/* + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.[Pp]ublish.xml +*.pfx +*.publishsettings +node_modules/ +bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Paket Package Manager Main exe +.paket/paket.exe + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store diff --git a/README.md b/README.md index 369e655..e1655a8 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,8 @@ A very lightweight & simple embedded http server for c# -Master | Provider ------- | -------- -[![Build Status][TeamCityImgMaster]][TeamCityLinkMaster] | Windows CI Provided By [JetBrains][] and [CodeBetter][] -[![Build status](https://ci.appveyor.com/api/projects/status/1schhjbpx7oomrx7)](https://ci.appveyor.com/project/shanielh/uHttpSharp) | Windows CI Provided By [AppVeyor][] -[![Build Status][MonoImgMaster]][MonoLinkMaster] | Mono CI Provided by [travis-ci][] - -[TeamCityImgMaster]:http://teamcity.codebetter.com/app/rest/builds/buildType:\(id:bt1191\)/statusIcon -[TeamCityLinkMaster]:http://teamcity.codebetter.com/viewLog.html?buildTypeId=bt1191&buildId=lastFinished&guest=1 - -[MonoImgMaster]:https://travis-ci.org/Code-Sharp/uHttpSharp.png?branch=master -[MonoLinkMaster]:https://travis-ci.org/Code-Sharp/uHttpSharp - -[travis-ci]:https://travis-ci.org/ -[AppVeyor]:http://www.appveyor.com/ -[JetBrains]:http://www.jetbrains.com/ -[CodeBetter]:http://codebetter.com/ - ## Usage -A [NuGet Package](https://www.nuget.org/packages/uHttpSharp/ "Go to µHttpSharp NuGet Package page") is available, Install via NuGet Package Manager : - - install-package uHttpSharp - A sample for usage : using (var httpServer = new HttpServer(new HttpRequestProvider())) diff --git a/uhttpsharp-demo/Handlers/TimingHandler.cs b/uhttpsharp-demo/Handlers/TimingHandler.cs index 91ab79e..f37504e 100644 --- a/uhttpsharp-demo/Handlers/TimingHandler.cs +++ b/uhttpsharp-demo/Handlers/TimingHandler.cs @@ -2,14 +2,14 @@ using System.Diagnostics; using System.Reflection; using System.Threading.Tasks; -using log4net; using uhttpsharp; +using uhttpsharp.Logging; namespace uhttpsharpdemo.Handlers { public class TimingHandler : IHttpRequestHandler { - private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog Logger = LogProvider.GetCurrentClassLogger(); public async Task Handle(IHttpContext context, Func next) { diff --git a/uhttpsharp-demo/Program.cs b/uhttpsharp-demo/Program.cs index 177737e..4d07921 100644 --- a/uhttpsharp-demo/Program.cs +++ b/uhttpsharp-demo/Program.cs @@ -37,8 +37,6 @@ internal static class Program { private static void Main() { - log4net.Config.XmlConfigurator.Configure(); - //var serverCertificate = X509Certificate.CreateFromCertFile(@"TempCert.cer"); using (var httpServer = new HttpServer(new HttpRequestProvider())) diff --git a/uhttpsharp-demo/packages.config b/uhttpsharp-demo/packages.config index a8e7b37..747efc5 100644 --- a/uhttpsharp-demo/packages.config +++ b/uhttpsharp-demo/packages.config @@ -1,5 +1,4 @@  - - + \ No newline at end of file diff --git a/uhttpsharp-demo/uhttpsharp.Demo.csproj b/uhttpsharp-demo/uhttpsharp.Demo.csproj index 7563180..62d1a20 100644 --- a/uhttpsharp-demo/uhttpsharp.Demo.csproj +++ b/uhttpsharp-demo/uhttpsharp.Demo.csproj @@ -39,12 +39,9 @@ false - - ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll - False - ..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll diff --git a/uhttpsharp.Tests/HttpMethodProviderCacheTests.cs b/uhttpsharp.Tests/HttpMethodProviderCacheTests.cs index 85a8f53..9f42c2d 100644 --- a/uhttpsharp.Tests/HttpMethodProviderCacheTests.cs +++ b/uhttpsharp.Tests/HttpMethodProviderCacheTests.cs @@ -1,9 +1,9 @@ -using Moq; -using NUnit.Framework; +using NSubstitute; +using Shouldly; +using Xunit; namespace uhttpsharp.Tests { - [TestFixture] public class HttpMethodProviderCacheTests { private const string MethodName = "Hello World"; @@ -13,44 +13,44 @@ private static IHttpMethodProvider GetTarget(IHttpMethodProvider child) return new HttpMethodProviderCache(child); } - [Test] + [Fact] public void Should_Call_Child_With_Right_Parameters() { // Arrange - var mock = new Mock(); - var target = GetTarget(mock.Object); + var mock = Substitute.For(); + var target = GetTarget(mock); // Act target.Provide(MethodName); // Assert - mock.Verify(m => m.Provide(MethodName), Times.Once); + mock.Received(1).Provide(MethodName); } - [Test] + [Fact] public void Should_Return_Same_Child_Value() { // Arrange const HttpMethods expectedMethod = HttpMethods.Post; - var mock = new Mock(); - var target = GetTarget(mock.Object); + var mock = Substitute.For(); + mock.Provide(MethodName).Returns(expectedMethod); + var target = GetTarget(mock); - mock.Setup(m => m.Provide(MethodName)).Returns(expectedMethod); // Act var actual = target.Provide(MethodName); // Assert - Assert.That(actual, Is.EqualTo(expectedMethod)); + actual.ShouldBe(expectedMethod); } - [Test] + [Fact] public void Should_Cache_The_Value() { // Arrange - var mock = new Mock(); - var target = GetTarget(mock.Object); + var mock = Substitute.For(); + var target = GetTarget(mock); // Act target.Provide(MethodName); @@ -58,7 +58,7 @@ public void Should_Cache_The_Value() target.Provide(MethodName); // Assert - mock.Verify(m => m.Provide(MethodName), Times.Once); + mock.Received(1).Provide(MethodName); } } diff --git a/uhttpsharp.Tests/HttpMethodProviderTests.cs b/uhttpsharp.Tests/HttpMethodProviderTests.cs index 4589c3a..be12a8d 100644 --- a/uhttpsharp.Tests/HttpMethodProviderTests.cs +++ b/uhttpsharp.Tests/HttpMethodProviderTests.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using NUnit.Framework; +using Shouldly; +using Xunit; namespace uhttpsharp.Tests { - [TestFixture] public class HttpMethodProviderTests { @@ -14,25 +14,35 @@ private static IHttpMethodProvider GetTarget() } - private IEnumerable Methods + public static IEnumerable Methods { get { return Enum.GetNames(typeof(HttpMethods)); } } - - [TestCaseSource("Methods")] - public void Should_Get_Right_Method(string methodName) + + [Theory] + [InlineData(HttpMethods.Connect)] + [InlineData(HttpMethods.Delete)] + [InlineData(HttpMethods.Get)] + [InlineData(HttpMethods.Head)] + [InlineData(HttpMethods.Options)] + [InlineData(HttpMethods.Patch)] + [InlineData(HttpMethods.Post)] + [InlineData(HttpMethods.Put)] + [InlineData(HttpMethods.Trace)] + public void Should_Get_Right_Method(HttpMethods method) { // Arrange + var methodName = Enum.GetName(typeof(HttpMethods), method); var target = GetTarget(); // Act var actual = target.Provide(methodName); // Assert - Assert.IsTrue(StringComparer.InvariantCultureIgnoreCase.Equals(actual.ToString(), methodName)); + actual.ToString().ShouldBe(methodName); } } diff --git a/uhttpsharp.Tests/packages.config b/uhttpsharp.Tests/packages.config index c90677c..b31a20b 100644 --- a/uhttpsharp.Tests/packages.config +++ b/uhttpsharp.Tests/packages.config @@ -1,5 +1,11 @@  - - + + + + + + + + \ No newline at end of file diff --git a/uhttpsharp.Tests/uhttpsharp.Tests.csproj b/uhttpsharp.Tests/uhttpsharp.Tests.csproj index 331fb8e..0d11c68 100644 --- a/uhttpsharp.Tests/uhttpsharp.Tests.csproj +++ b/uhttpsharp.Tests/uhttpsharp.Tests.csproj @@ -1,5 +1,7 @@  + + Debug @@ -13,6 +15,7 @@ 512 ..\ true + 84fe69d3 true @@ -32,11 +35,11 @@ 4 - - ..\packages\Moq.4.2.1312.1622\lib\net40\Moq.dll + + ..\packages\NSubstitute.1.8.1.0\lib\net45\NSubstitute.dll - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + ..\packages\Shouldly.2.4.0\lib\net40\Shouldly.dll @@ -45,6 +48,15 @@ + + ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + + + ..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll + + + ..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll + @@ -60,8 +72,18 @@ uhttpsharp + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + +