|
From: <thi...@gm...> - 2005-05-24 12:24:18
|
Hi Johan
have a look at my previous post named SetupResult behavior and NMO-37
(indexed properties). Here's the current state of my "investigation"
(I'm discovering the source so please bear with me ;)
1/ About c# indexed properties, with SetupResult and ExpectAndReturn
Actually SetupResult works for index property if there is only one
index definition, eg the following does work :
public interface IFoo
{
=09string this[int index] { get; }
}
[Test]
public void UniqueIndexedProperty()
{
=09DynamicMock mock =3D new DynamicMock(typeof(IFoo));
=09mock.SetupResult("Item","TheValue",typeof(int));
=09IFoo foo =3D (IFoo)mock.MockInstance;
=09Assert.AreEqual("TheValue",foo[45]);
}
The failure appears when you have more than one index, eg:
public interface IFoo
{
=09string this[int index] { get; }
=09string this[string index] { get; }
}
as this leads to ambiguous match and other issues the way it's
currently implemented. So actually indexed properties do work for
SetupResult as long as there is no more than one index... The same
applies for ExpectAndReturn.
2/ about non c# indexed properties
Did you actually already try to use non c# index properties (with only
one index) ? I didn't test that, but I suppose it could already work
as long as you only have one index defined (else we go back to issue
described in 1/).
3/ about helping
sure you can. What I'd like to get first is a test fixture to isolate
each of the cases we want to implement (more or less what I wrote
above, but for each case : one indexed property with setupresult, one
with expectandreturn, two with setupresult, two with expectandreturn).
=3D> to other nmock devs: in order to fix this, we would have to change
the way we store the expectations / method registrations, which use
the method name as a key in current code (see _methods Hashtable), and
use something (such as the signature) which takes the parameters types
into account in the key. Any opinion before I try to proceed ?
kind regards
Thibaut
2005/5/24, Johan Appelgren <joh...@gm...>:
> On 5/16/05, Thibaut Barr=E8re <thi...@gm...> wrote:
> > If nothing has already been done for this one, I can look at it
> > (unless there are more critical issues)
> >
> > Thibaut
>=20
> Have you had time to make any progress on this?
>=20
> If support for the only indexed property that C# can generate is
> added, would it be possible to also extend it to support indexed
> properties generally. Like for those that can be defined using managed
> c++? The reason for this is that I want to mock some com interop
> interfaces that use indexed properties extensively.
>=20
> If I can help in some way let me know.
>=20
> /Johan
>
|