Hi there,
I've tried Googling this but turned up no results - was hoping I could
get some guidance from the list. Basically i've got a class which has
an expectation that AssertWasCalled on a method which takes in a List
as a parameter. If i call it twice with two new'ed up lists, the
framework fails the assertion citing "Expected #1, Actual #2".
I've devised the following test-case to reproduce the situation:
/************/
using System.Collections.Generic;
using NUnit.Framework;
using Rhino.Mocks;
namespace Test
{
[TestFixture]
public class ATest
{
private IActor _mockActor;
private Manager _manager;
private List<int> _list1, _list2;
[SetUp]
public void SetUp()
{
_list1 = new List<int>();
// _list1.Add(0);
_list2 = new List<int>();
_mockActor = MockRepository.GenerateMock<IActor>();
_manager = new Manager(_mockActor);
_manager.DoItOnActor(_list1);
_manager.DoItOnActor(_list2);
}
[Test]
public void ShouldPerformActionOnList1()
{
_mockActor.AssertWasCalled(x => x.PerformAction(_list1));
}
[Test]
public void ShouldPerformActionOnList2()
{
_mockActor.AssertWasCalled(x => x.PerformAction(_list2));
}
}
public interface IActor
{
void PerformAction(List<int> list);
}
public class Manager
{
private readonly IActor _actor;
public Manager(IActor actor)
{
_actor = actor;
}
public void DoItOnActor(List<int> dataForActor)
{
_actor.PerformAction(dataForActor);
}
}
}
/***********/
If I uncomment the second line in the set-up, Rhino seems to treat the
lists differently and the expectations pass. However, because they are
different lists (they just happen to both be empty in this scenario),
I believe I should be able to call them like that and the scenario
should pass. Any hints?
Thanks,
Xerx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---