Skip to content

Commit 80b1fb7

Browse files
committed
Changed MainProject Logging from log4net to LibLog and Updated Newtonsoft.Json
Changed Tests to use XUnit, Shoudly and NSubstitute
1 parent a074a31 commit 80b1fb7

17 files changed

+2257
-65
lines changed

.gitignore

+225-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,227 @@
1-
/_ReSharper.uhttpsharp/
2-
/*.6.0.ReSharper.user
3-
/*.suo
4-
/packages/*
5-
*/bin/*
6-
*/obj/*
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
build/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
24+
# Visual Studio 2015 cache/options directory
25+
*.vs/
26+
27+
# Roslyn cache directories
28+
*.ide/
29+
30+
# MSTest test Results
31+
[Tt]est[Rr]esult*/
32+
[Bb]uild[Ll]og.*
33+
34+
# NUnit
35+
*.VisualState.xml
36+
TestResult.xml
37+
38+
# Build Results of an ATL Project
39+
[Dd]ebugPS/
40+
[Rr]eleasePS/
41+
dlldata.c
42+
43+
*_i.c
44+
*_p.c
45+
*.ilk
46+
*.meta
47+
*.obj
48+
*.pch
49+
*.pdb
50+
*.pgc
51+
*.pgd
52+
*.rsp
53+
*.sbr
54+
*.tlb
55+
*.tli
56+
*.tlh
57+
*.tmp
58+
*.tmp_proj
59+
*.log
60+
*.vspscc
61+
*.vssscc
62+
.builds
63+
*.pidb
64+
*.log
65+
*.scc
66+
67+
# Chutzpah Test files
68+
_Chutzpah*
69+
70+
# Visual C++ cache files
71+
ipch/
72+
*.aps
73+
*.ncb
74+
*.opensdf
75+
*.sdf
76+
*.cachefile
77+
78+
# Visual Studio profiler
779
*.psess
880
*.vsp
9-
*.nupkg
81+
*.vspx
82+
83+
# TFS 2012 Local Workspace
84+
$tf/
85+
86+
# Guidance Automation Toolkit
87+
*.gpState
88+
89+
# ReSharper is a .NET coding add-in
90+
_ReSharper*/
91+
*.[Rr]e[Ss]harper
92+
*.DotSettings.user
93+
94+
# JustCode is a .NET coding addin-in
95+
.JustCode
96+
97+
# TeamCity is a build add-in
98+
_TeamCity*
99+
100+
# DotCover is a Code Coverage Tool
101+
*.dotCover
102+
103+
# NCrunch
104+
*.ncrunch*
105+
.*crunch*.local.xml
106+
107+
# MightyMoose
108+
*.mm.*
109+
AutoTest.Net/
110+
111+
# Web workbench (sass)
112+
.sass-cache/
113+
114+
# Installshield output folder
115+
[Ee]xpress/
116+
117+
# DocProject is a documentation generator add-in
118+
DocProject/buildhelp/
119+
DocProject/Help/*.HxT
120+
DocProject/Help/*.HxC
121+
DocProject/Help/*.hhc
122+
DocProject/Help/*.hhk
123+
DocProject/Help/*.hhp
124+
DocProject/Help/Html2
125+
DocProject/Help/html
126+
127+
# Click-Once directory
128+
publish/
129+
130+
# Publish Web Output
131+
*.[Pp]ublish.xml
132+
*.azurePubxml
133+
## TODO: Comment the next line if you want to checkin your
134+
## web deploy settings but do note that will include unencrypted
135+
## passwords
136+
*.pubxml
137+
*.publishproj
138+
139+
# NuGet Packages Directory
140+
packages/*
141+
*.nupkg
142+
143+
## TODO: If the tool you use requires repositories.config
144+
## uncomment the next line
145+
#!packages/repositories.config
146+
147+
# Enable "build/" folder in the NuGet Packages folder since
148+
# NuGet packages use it for MSBuild targets.
149+
# This line needs to be after the ignore of the build folder
150+
# (and the packages folder if the line above has been uncommented)
151+
!packages/build/
152+
153+
# PVC Build packages (https://github.com/pvcbuild/pvc)
154+
pvc-packages/*
155+
156+
# Windows Azure Build Output
157+
csx
158+
*.build.csdef
159+
160+
# Windows Store app package directory
161+
AppPackages/
162+
163+
# Others
164+
sql/
165+
*.Cache
166+
ClientBin/
167+
[Ss]tyle[Cc]op.*
168+
~$*
169+
*~
170+
*.dbmdl
171+
*.dbproj.schemaview
172+
*.[Pp]ublish.xml
173+
*.pfx
174+
*.publishsettings
175+
node_modules/
176+
bower_components/
177+
178+
# RIA/Silverlight projects
179+
Generated_Code/
180+
181+
# Backup & report files from converting an old project file to a newer
182+
# Visual Studio version. Backup files are not needed, because we have git ;-)
183+
_UpgradeReport_Files/
184+
Backup*/
185+
UpgradeLog*.XML
186+
UpgradeLog*.htm
187+
188+
# SQL Server files
189+
App_Data/*.mdf
190+
App_Data/*.ldf
191+
192+
# Business Intelligence projects
193+
*.rdl.data
194+
*.bim.layout
195+
*.bim_*.settings
196+
197+
# Microsoft Fakes
198+
FakesAssemblies/
199+
200+
# Node.js Tools for Visual Studio
201+
.ntvs_analysis.dat
202+
203+
# Visual Studio 6 build log
204+
*.plg
205+
206+
# Visual Studio 6 workspace options file
207+
*.opt
208+
209+
# Paket Package Manager Main exe
210+
.paket/paket.exe
211+
212+
# =========================
213+
# Windows detritus
214+
# =========================
215+
216+
# Windows image file caches
217+
Thumbs.db
218+
ehthumbs.db
219+
220+
# Folder config file
221+
Desktop.ini
222+
223+
# Recycle Bin used on file shares
224+
$RECYCLE.BIN/
225+
226+
# Mac crap
227+
.DS_Store

uhttpsharp-demo/Handlers/TimingHandler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using System.Diagnostics;
33
using System.Reflection;
44
using System.Threading.Tasks;
5-
using log4net;
65
using uhttpsharp;
6+
using uhttpsharp.Logging;
77

88
namespace uhttpsharpdemo.Handlers
99
{
1010
public class TimingHandler : IHttpRequestHandler
1111
{
12-
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
12+
private static readonly ILog Logger = LogProvider.GetCurrentClassLogger();
1313

1414
public async Task Handle(IHttpContext context, Func<Task> next)
1515
{

uhttpsharp-demo/Program.cs

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ internal static class Program
3737
{
3838
private static void Main()
3939
{
40-
log4net.Config.XmlConfigurator.Configure();
41-
4240
//var serverCertificate = X509Certificate.CreateFromCertFile(@"TempCert.cer");
4341

4442
using (var httpServer = new HttpServer(new HttpRequestProvider()))

uhttpsharp-demo/packages.config

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="log4net" version="2.0.3" targetFramework="net45" />
4-
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
3+
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
54
</packages>

uhttpsharp-demo/uhttpsharp.Demo.csproj

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@
3939
<Prefer32Bit>false</Prefer32Bit>
4040
</PropertyGroup>
4141
<ItemGroup>
42-
<Reference Include="log4net">
43-
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
44-
</Reference>
4542
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4643
<SpecificVersion>False</SpecificVersion>
47-
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
44+
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
4845
</Reference>
4946
<Reference Include="System" />
5047
<Reference Include="System.Core" />

uhttpsharp.Tests/HttpMethodProviderCacheTests.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using Moq;
2-
using NUnit.Framework;
1+
using NSubstitute;
2+
using Shouldly;
3+
using Xunit;
34

45
namespace uhttpsharp.Tests
56
{
6-
[TestFixture]
77
public class HttpMethodProviderCacheTests
88
{
99
private const string MethodName = "Hello World";
@@ -13,52 +13,52 @@ private static IHttpMethodProvider GetTarget(IHttpMethodProvider child)
1313
return new HttpMethodProviderCache(child);
1414
}
1515

16-
[Test]
16+
[Fact]
1717
public void Should_Call_Child_With_Right_Parameters()
1818
{
1919
// Arrange
20-
var mock = new Mock<IHttpMethodProvider>();
21-
var target = GetTarget(mock.Object);
20+
var mock = Substitute.For<IHttpMethodProvider>();
21+
var target = GetTarget(mock);
2222

2323
// Act
2424
target.Provide(MethodName);
2525

2626
// Assert
27-
mock.Verify(m => m.Provide(MethodName), Times.Once);
27+
mock.Received(1).Provide(MethodName);
2828
}
2929

30-
[Test]
30+
[Fact]
3131
public void Should_Return_Same_Child_Value()
3232
{
3333
// Arrange
3434
const HttpMethods expectedMethod = HttpMethods.Post;
3535

36-
var mock = new Mock<IHttpMethodProvider>();
37-
var target = GetTarget(mock.Object);
36+
var mock = Substitute.For<IHttpMethodProvider>();
37+
mock.Provide(MethodName).Returns(expectedMethod);
38+
var target = GetTarget(mock);
3839

39-
mock.Setup(m => m.Provide(MethodName)).Returns(expectedMethod);
4040

4141
// Act
4242
var actual = target.Provide(MethodName);
4343

4444
// Assert
45-
Assert.That(actual, Is.EqualTo(expectedMethod));
45+
actual.ShouldBe(expectedMethod);
4646
}
4747

48-
[Test]
48+
[Fact]
4949
public void Should_Cache_The_Value()
5050
{
5151
// Arrange
52-
var mock = new Mock<IHttpMethodProvider>();
53-
var target = GetTarget(mock.Object);
52+
var mock = Substitute.For<IHttpMethodProvider>();
53+
var target = GetTarget(mock);
5454

5555
// Act
5656
target.Provide(MethodName);
5757
target.Provide(MethodName);
5858
target.Provide(MethodName);
5959

6060
// Assert
61-
mock.Verify(m => m.Provide(MethodName), Times.Once);
61+
mock.Received(1).Provide(MethodName);
6262
}
6363

6464
}

0 commit comments

Comments
 (0)