Remoting mock and IDisposable

36 views
Skip to first unread message

ikr...@gmail.com

unread,
Nov 4, 2009, 11:43:31 PM11/4/09
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());
}
}
}
Reply all
Reply to author
Forward
0 new messages