Skip to content

Commit

Permalink
Changed MainProject Logging from log4net to LibLog and Updated Newton…
Browse files Browse the repository at this point in the history
…soft.Json

Changed Tests to use XUnit, Shoudly and NSubstitute
  • Loading branch information
madhon committed Mar 19, 2015
1 parent a074a31 commit 80b1fb7
Show file tree
Hide file tree
Showing 17 changed files with 2,257 additions and 65 deletions.
232 changes: 225 additions & 7 deletions .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
*.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
4 changes: 2 additions & 2 deletions uhttpsharp-demo/Handlers/TimingHandler.cs
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
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
@@ -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
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
@@ -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

0 comments on commit 80b1fb7

Please sign in to comment.