Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Log4net and use LibLog for logging #13

Merged
merged 3 commits into from
Mar 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 225 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
*.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
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
4 changes: 2 additions & 2 deletions uhttpsharp-demo/Handlers/TimingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Task> next)
{
Expand Down
2 changes: 0 additions & 2 deletions uhttpsharp-demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
3 changes: 1 addition & 2 deletions uhttpsharp-demo/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
</packages>
5 changes: 1 addition & 4 deletions uhttpsharp-demo/uhttpsharp.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
32 changes: 16 additions & 16 deletions uhttpsharp.Tests/HttpMethodProviderCacheTests.cs
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -13,52 +13,52 @@ 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<IHttpMethodProvider>();
var target = GetTarget(mock.Object);
var mock = Substitute.For<IHttpMethodProvider>();
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<IHttpMethodProvider>();
var target = GetTarget(mock.Object);
var mock = Substitute.For<IHttpMethodProvider>();
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<IHttpMethodProvider>();
var target = GetTarget(mock.Object);
var mock = Substitute.For<IHttpMethodProvider>();
var target = GetTarget(mock);

// Act
target.Provide(MethodName);
target.Provide(MethodName);
target.Provide(MethodName);

// Assert
mock.Verify(m => m.Provide(MethodName), Times.Once);
mock.Received(1).Provide(MethodName);
}

}
Expand Down
Loading