Hi!

I've a problem setting up a test for an Equals method on an object.

The object in question is defined by this interface:

    public interface IHours {
        ITimeOfDay OpenAt { get; set; }
        ITimeOfDay CloseAt { get; set; }
        DateTime ValidFrom { get; set; }
        DateTime ValidTo { get; set; }
        bool isCovered(DateTime time);
    }

and it contains references to ITimeOfDay defined such:

    public interface ITimeOfDay {
        DateTime Time { get; set; }
        int Hour { get; }
        int Minute { get; }
        int Second { get; }
    }

Now I want the Equals of the Hours : IHours to check the OpenAt and
CloseAt IHours. To set this up I try to stub those property-values
out, and just return true and false depending on what my particular
test needs them to be.

        [SetUp]
        public virtual void SetUp() {
            mocks = new MockRepository();

            defaultHours = getHours();
            otherHours = getHours();

        }

        [TearDown]
        public virtual void TearDown() {
            mocks.ReplayAll();
            mocks.VerifyAll();
        }

        [Test(Description = "Equals on two Hours should regard the
fields")]
        public void Equals_TwoValueEqualledObjects_Equal() {
            var openAt = mocks.Stub<ITimeOfDay>();
            var closeAt = mocks.Stub<ITimeOfDay>();

            closeAt                                   //this is line
66, referenced in the error stacktrace
                .Stub(o => o.Equals(null))
                .IgnoreArguments()
                .Return(true);

            openAt
                .Stub(c => c.Equals(null))
                .IgnoreArguments()
                .Return(true);
            mocks.ReplayAll();

            defaultHours.OpenAt = openAt;
            otherHours.OpenAt = openAt;

            defaultHours.CloseAt = closeAt;
            defaultHours.CloseAt = closeAt;

            Assert.That(defaultHours, Is.EqualTo(otherHours));
            Assert.That(defaultHours.GetHashCode(), Is.EqualTo
(otherHours.GetHashCode()));
        }

But I get this cryptic error when I run it:

System.InvalidOperationException: Type 'System.Boolean' doesn't match
the return type 'System.Collections.Generic.IList`1
[NOIS.Model.Interfaces.IAircraft]' for method
'IAircraftType.get_Aircrafts();'
at Rhino.Mocks.Expectations.AbstractExpectation.AssertTypesMatches
(Object value)
at Rhino.Mocks.Expectations.AbstractExpectation.set_ReturnValue(Object
value)
at Rhino.Mocks.Impl.MethodOptions`1.Return(T objToReturn)
at
Nois.Test.Model.Entities.HoursTest.Equals_TwoValueEqualledObjects_Equal
() in HoursTest.cs: line 66

The IAircraftType interface is a part of the same namespace, but
nowhere in the test, interface or implementing class is it referenced.
I do not understand why it interferes. There is no reference to it as
far as I can gather.

I am using
- Rhino.Mocks v3.5.0.1337
- NUnit.Framework v2.5.0.8332

Anyone have any idea?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to