My favorites
|
Sign in
mocking-frameworks-compare
A set of test cases to compare different mocking frameworks available in .NET
Project Home
Downloads
Wiki
Issues
Source
Checkout
|
Browse
|
Changes
|
r95
Source path:
svn
/
trunk
/
Tests
/
CS
/
StubsTests
/
BrainTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using MockingFrameworksCompare.BrainSample;
using NUnit.Framework;
using MockingFrameworksCompare.BrainSample.Stubs;
namespace StubsTests
{
/// <summary>
/// Brain test implementation using Stubs.
/// Stubs home page: http://research.microsoft.com/stubs
/// </summary>
[TestFixture]
public class BrainTests
{
/// <summary>
/// Verify that if hand throws an exception having touched a hot iron, <see cref="IMouth.Yell"/> gets called.
/// </summary>
/// <remarks>
/// Stubs can mock both interfaces and classes - however, only virtual methods
/// of a class can be mocked (try changing IHand/IMouth to Hand/Mouth).
/// </remarks>
[Test]
public void TouchHotIron_Yell()
{
var hand = new SIHand();
var mouth = new SIMouth();
hand.TouchIron = (iron) =>
{
if (iron.IsHot)
throw new BurnException();
};
bool yelled = false;
mouth.Yell = () => yelled = true;
var brain = new Brain(hand, mouth);
brain.TouchIron(new Iron { IsHot = true });
Assert.IsTrue(yelled);
}
}
}
Show details
Hide details
Change log
r56
by jonathan.dehalleux on Apr 21, 2009
Diff
added stubs framework examples
Go to:
/trunk/Frameworks/Stubs
...bs/Microsoft.Stubs.Framework.dll
...bs/Microsoft.Stubs.Framework.xml
/trunk/Frameworks/Stubs/readme.txt
/trunk/MockingFrameworksCompare.sln
...S/Performance/Performance.csproj
.../Tests/CS/Performance/Program.cs
/trunk/Tests/CS/StubsTests
...ests/CS/StubsTests/BrainTests.cs
...ingFrameworksCompare.Designer.cs
...s/MockingFrameworksCompare.stubx
...k/Tests/CS/StubsTests/Properties
...Tests/Properties/AssemblyInfo.cs
.../StubsTests/ShoppingCartTests.cs
.../CS/StubsTests/StubsTests.csproj
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1286 bytes, 41 lines
View raw file
Hosted by