MoleNotImplementedException
-
Monday, April 23, 2012 12:40 PM
Hi,
I'm a newbie with Moles so forgive the simple question but according to documentation I think this should work:
MDataServiceCollection<string> dataServiceCollectionMock =
new MDataServiceCollection<string>(); new MCollection<string>(dataServiceCollectionMock) { SystemCollectionsIEnumerableGetEnumerator = () => { return new List<string>(new string[] { "a", "b", "c" }).GetEnumerator(); } }; string result = string.Empty; foreach (string s in dataServiceCollectionMock.Instance) { result += s; }I'm replacing GetEnumerator with my own implementation so that I can inject the values I iterate through when using an instance of DataServiceCollection. I'm expecting s to return "abc". However I get the following exception thrown:
Microsoft.Moles.Framework.Moles.MoleNotImplementedException: Collection`1.GetEnumerator() was not moled.
Any help greatly appreciated.
Regards, Chris.
All Replies
-
Tuesday, April 24, 2012 8:46 AMModerator
Hi Christopher,
As the PEX and Mole team mentioned that they will migrate to forums stackoverflow.com, you could get better help from there.
Hope this could help you.
Tony Xiao [MSFT]
MSDN Community Support | Feedback to us
- Edited by Tony xiaoModerator Tuesday, April 24, 2012 8:50 AM
-
Wednesday, April 25, 2012 8:07 AM
Worked out the answer.
Rather than:
SystemCollectionsIEnumerableGetEnumerator = () => { return new List<string>(new string[] { "a", "b", "c" }).GetEnumerator(); }Should be:
GetEnumerator = () => { return new List<string>(new string[] { "a", "b", "c" }).GetEnumerator(); }Regards, Chris.
- Marked As Answer by Christopher Owczarek Wednesday, April 25, 2012 8:07 AM

