Skip to content

Commit c68b0bc

Browse files
author
dnewman
committed
Added rhino test extensions
1 parent a3bb9f5 commit c68b0bc

18 files changed

+5684
-26
lines changed

lib/Rhino-3.6/Rhino.Mocks.dll

309 KB
Binary file not shown.

lib/Rhino-3.6/Rhino.Mocks.xml

Lines changed: 5413 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Rhino-3.6/acknowledgements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Rhino Mocks is using Castle Dynamic Proxy (http://www.castleproject.org/dynamicproxy/index.html) to handle proxying the types it needs to mock.
2+
The Dynamic Proxy project has been invaluable resource and made creating Rhino Mocks possible.

lib/Rhino-3.6/license.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2005 - 2009 Ayende Rahien (ayende@ayende.com)
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice,
8+
this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above copyright notice,
10+
this list of conditions and the following disclaimer in the documentation
11+
and/or other materials provided with the distribution.
12+
* Neither the name of Ayende Rahien nor the names of its
13+
contributors may be used to endorse or promote products derived from this
14+
software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/Shouldly/Create.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Rhino.Mocks;
2+
3+
namespace Shouldly
4+
{
5+
public static class Create
6+
{
7+
public static T Mock<T>() where T : class
8+
{
9+
return MockRepository.GenerateMock<T>();
10+
}
11+
12+
public static T Stub<T>() where T : class
13+
{
14+
return MockRepository.GenerateStub<T>();
15+
}
16+
17+
public static T Partial<T>(params object[] constructorArgs) where T : class
18+
{
19+
return new MockRepository().PartialMock<T>(constructorArgs);
20+
}
21+
}
22+
}

src/Shouldly/ObjectHelpers.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Shouldly
2+
{
3+
public static class ObjectHelpers
4+
{
5+
public static T As<T>(this object o)
6+
{
7+
return (T)o;
8+
}
9+
}
10+
}
Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
using System.Diagnostics;
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Text.RegularExpressions;
25
using NUnit.Framework;
6+
using Shouldly;
37

48
namespace Shouldly
59
{
@@ -9,12 +13,38 @@ public static class ShouldBeStringTestExtensions
913
{
1014
public static void ShouldBeCloseTo(this string actual, object expected)
1115
{
12-
actual.Quotify()
13-
.StripWhitespace()
14-
.AssertAwesomely(Is.EqualTo(
15-
(expected ?? "NULL").ToString()
16-
.Quotify()
17-
.StripWhitespace()), actual, expected);
16+
// const string pattern = @"\s+";
17+
// var testActual = Regex.Split(actual, pattern);
18+
// var testExpected = Regex.Split((expected ?? "NULL").ToString(), pattern);
19+
//
20+
// var actualIndex = 0;
21+
// var expectedIndex = 0; //new StringReader((expected ?? "NULL").ToString());
22+
//
23+
// var actualBuffer = actual;
24+
// var expectedBuffer = (expected ?? "NULL").ToString();
25+
//
26+
// var stringsAreMatching = true;
27+
// while (stringsAreMatching)
28+
// {
29+
// var actualNextBreak = Regex.Match(actualBuffer, pattern).Index;
30+
// var expectedNextBreak = Regex.Match(expectedBuffer, pattern).Index;
31+
// if (actualNextBreak > -1 && expectedNextBreak > -1)
32+
// {
33+
// actualIndex += actualNextBreak;
34+
// expectedIndex += expectedNextBreak;
35+
//
36+
// var actualTest = actualBuffer.Substring(0, actualNextBreak);
37+
// var expectedTest = expectedBuffer.Substring(0, expectedNextBreak);
38+
// stringsAreMatching = actualTest.Equals(expectedTest, StringComparison.CurrentCultureIgnoreCase);
39+
//
40+
// actualBuffer = actualBuffer.Substring(actualNextBreak);
41+
// expectedBuffer = expectedBuffer.Substring(actualNextBreak);
42+
// }
43+
// }
44+
var strippedActual = actual.Quotify().StripWhitespace();
45+
var strippedExpected = (expected ?? "NULL").ToString().Quotify().StripWhitespace();
46+
47+
strippedActual.AssertAwesomely(Is.EqualTo(strippedExpected), actual, expected);
1848
}
1949

2050
public static void ShouldContain(this string actual, string expected)
@@ -26,10 +56,5 @@ public static void ShouldNotContain(this string actual, string expected)
2656
{
2757
actual.AssertAwesomely(Is.Not.StringContaining(expected).IgnoreCase, actual, expected);
2858
}
29-
30-
public static void ShouldBeGreaterThan(this int actual, int expected)
31-
{
32-
actual.AssertAwesomely(Is.GreaterThan(expected), actual, expected);
33-
}
3459
}
3560
}

src/Shouldly/ShouldBeTestExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,15 @@ public static void ShouldBe(this double actual, double expected, double toleranc
2626
{
2727
actual.AssertAwesomely(Is.EqualTo(expected).Within(tolerance), actual, expected);
2828
}
29+
30+
public static void ShouldBeGreaterThan(this object actual, object expected)
31+
{
32+
actual.AssertAwesomely(Is.GreaterThan(expected), actual, expected);
33+
}
34+
35+
public static void ShouldBeLessThan(this object actual, object expected)
36+
{
37+
actual.AssertAwesomely(Is.LessThan(expected), actual, expected);
38+
}
2939
}
3040
}

src/Shouldly/ShouldThrowTestExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Shouldly
66
{
77
[DebuggerStepThrough]
8-
[ShouldlyMethods]
98
public static class Should
109
{
1110
public static string Throw<EXCEPTION>(Action actual) where EXCEPTION : Exception
@@ -20,6 +19,5 @@ public static string Throw<EXCEPTION>(Action actual) where EXCEPTION : Exception
2019
}
2120
throw new AssertionException(new ShouldlyMessage(actual).ToString());
2221
}
23-
2422
}
2523
}

src/Shouldly/Shouldly.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<Reference Include="nunit.framework">
3535
<HintPath>..\..\lib\NUnit-2.5.3.9345\nunit.framework.dll</HintPath>
3636
</Reference>
37+
<Reference Include="Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
38+
<SpecificVersion>False</SpecificVersion>
39+
<HintPath>..\..\lib\Rhino-3.6\Rhino.Mocks.dll</HintPath>
40+
</Reference>
3741
<Reference Include="System" />
3842
<Reference Include="System.Core">
3943
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -51,13 +55,16 @@
5155
<Reference Include="System.Xml" />
5256
</ItemGroup>
5357
<ItemGroup>
58+
<Compile Include="Create.cs" />
59+
<Compile Include="ObjectHelpers.cs" />
5460
<Compile Include="Properties\AssemblyInfo.cs" />
5561
<Compile Include="ShouldBeEnumerableTestExtensions.cs" />
5662
<Compile Include="ShouldBeStringTestExtensions.cs" />
5763
<Compile Include="ShouldBeTestExtensions.cs" />
5864
<Compile Include="ShouldlyCoreExtensions.cs" />
5965
<Compile Include="ShouldlyMessage.cs" />
6066
<Compile Include="ShouldlyMethodsAttribute.cs" />
67+
<Compile Include="ShouldlyRhinoExtensions.cs" />
6168
<Compile Include="ShouldThrowTestExtensions.cs" />
6269
<Compile Include="StringHelpers.cs" />
6370
</ItemGroup>

0 commit comments

Comments
 (0)