ikr...@gmail.com
unread,Nov 4, 2009, 11:43:31 PM11/4/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino.Mocks
I am having trouble asserting calls to IDisposable.Dispose. See the
failing test below. It works fine for other types of mocks, but fails
for the remoting mock. It makes it not possible to verify that Dispose
() is called correctly, which is very annoying. Amazingly, the second
test that calls Dispose() explicitly succeeds.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
namespace RhinoMocksIDisposableTrouble
{
public class MClass : MarshalByRefObject, IDisposable
{
public void Dispose() { }
}
[TestClass]
public class DisposableTest
{
[TestMethod]
public void Using_Works_For_MClass()
{
var mock = MockRepository.GenerateMock<MClass>();
using (mock) { }
mock.AssertWasCalled(x => x.Dispose());
}
[TestMethod]
public void Dispose_Works_For_MClass()
{
var mock = MockRepository.GenerateMock<MClass>();
mock.Dispose();
mock.AssertWasCalled(x => x.Dispose());
}
}
}