Skip to content

Commit

Permalink
First go at feature parity for AAA with rec/pb: Partials, Multis, and…
Browse files Browse the repository at this point in the history
… Stricts

git-svn-id: https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk@2214 079b0acf-d9fa-0310-9935-e5ade295c882
  • Loading branch information
abombss committed Jul 6, 2009
1 parent 3c85489 commit c3b5a31
Show file tree
Hide file tree
Showing 8 changed files with 821 additions and 191 deletions.
461 changes: 461 additions & 0 deletions Rhino.Mocks.Tests/MultiMocksWithAAA.cs

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions Rhino.Mocks.Tests/PartialMockTestsAAA.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#region license

// Copyright (c) 2005 - 2007 Ayende Rahien ([email protected])
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Ayende Rahien nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;
using MbUnit.Framework;
using Rhino.Mocks.Exceptions;

namespace Rhino.Mocks.Tests
{
[TestFixture]
public class PartialMockTestsAAA
{
private AbstractClass abs;

[SetUp]
public void SetUp()
{
abs = (AbstractClass) MockRepository.GeneratePartialMock(typeof (AbstractClass), new Type[] {});
}

[Test]
public void AutomaticallCallBaseMethodIfNoExpectationWasSet()
{
Assert.AreEqual(1, abs.Increment());
Assert.AreEqual(6, abs.Add(5));
Assert.AreEqual(6, abs.Count);
abs.VerifyAllExpectations();
}

[Test]
public void CanMockVirtualMethods()
{
abs.Expect(x => x.Increment()).Return(5);
abs.Expect(x => x.Add(2)).Return(3);

Assert.AreEqual(5, abs.Increment());
Assert.AreEqual(3, abs.Add(2));
Assert.AreEqual(0, abs.Count);
abs.VerifyAllExpectations();
}

[Test]
public void CanMockAbstractMethods()
{
abs.Expect(x => x.Decrement()).Return(5);
Assert.AreEqual(5, abs.Decrement());
Assert.AreEqual(0, abs.Count);
abs.VerifyAllExpectations();
}

[Test]
[ExpectedException(typeof (InvalidOperationException), "Can't create a partial mock from an interface")]
public void CantCreatePartialMockFromInterfaces()
{
MockRepository.GeneratePartialMock<IDemo>();
}

[Test]
[ExpectedException(typeof (ExpectationViolationException), "AbstractClass.Decrement(); Expected #0, Actual #1.")]
public void CallAnAbstractMethodWithoutSettingExpectation()
{
abs.Decrement();
}

[Test]
public void CanMockWithCtorParams()
{
var withParameters = MockRepository.GeneratePartialMock<WithParameters>(1);
withParameters.Expect(x => x.Int).Return(4);
Assert.AreEqual(4, withParameters.Int);
withParameters.VerifyAllExpectations();
}
}
}
44 changes: 20 additions & 24 deletions Rhino.Mocks.Tests/Rhino.Mocks.Tests 3.5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\SharedLibs\Castle\Castle.DynamicProxy2.dll</HintPath>
</Reference>
<Reference Include="Interop.ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\SharedLibs\Interop\Interop.ADODB.dll</HintPath>
</Reference>
<Reference Include="Interop.MSHTML, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\SharedLibs\Interop\Interop.MSHTML.dll</HintPath>
</Reference>
<Reference Include="MbUnit.Framework, Version=1.0.2531.41788, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\SharedLibs\Tools\MbUnit\MbUnit.Framework.dll</HintPath>
Expand Down Expand Up @@ -144,6 +152,8 @@
<Compile Include="Constraints\StringConstraintsTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PartialMockTestsAAA.cs" />
<Compile Include="MultiMocksWithAAA.cs" />
<Compile Include="Coverage.cs" />
<Compile Include="CustomAttributesOnMocks.cs" />
<Compile Include="DoNotExpectTests.cs" />
Expand Down Expand Up @@ -397,30 +407,6 @@
<Project>{1E8FECC7-9E9B-4275-A938-D956F5E5D4F8}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
<COMReference Include="ADODB">
<Guid>{2A75196C-D9EB-4129-B803-931327F72D5C}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>8</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="MSHTML">
<Guid>{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}</Guid>
<VersionMajor>4</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="Scripting">
<Guid>{420B2830-E718-11CF-893D-00A0C9054228}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<ItemGroup>
<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
Expand All @@ -447,5 +433,15 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<COMReference Include="Scripting">
<Guid>{420B2830-E718-11CF-893D-00A0C9054228}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion Rhino.Mocks.Tests/default.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<include name="Rhino.Mocks.dll" />
<include name="Rhino.Mocks.Tests.Model.dll" />
<include name="Interop.ADODB.dll" />
<include name="Interop.mshtml.dll" />
<include name="Interop.MSHTML.dll" />
<include name="Scripting.dll" />
<include name="Rhino.Mocks.CPP.Interfaces.dll" />
<include name="Castle.DynamicProxy2.dll" if="${skip.merge.asm}" />
Expand Down
Loading

0 comments on commit c3b5a31

Please sign in to comment.