Hi,
I have a test method where I am trying to fake returning an empty collection.
It works when I write
Isolate.WhenCalled(() => fakeResourceManager.Enumerate<SetResource>(fakeCriteria)).WillReturn(new Collection<SetResource>());
However throws an exception when I write.
List<SetResource> fakeCollection = new List<SetResource>();
Isolate.WhenCalled(() => fakeResourceManager.Enumerate<SetResource>(fakeCriteria)).WillReturnCollectionValuesOf(fakeCollection);
The exception thrown is -
Cannot swap MsCorLib type: System.Collections.ObjectModel.Collection`1[MyClass.SetResource]
The test method...
[TestMethod()]
public void AAACheckProvisioningAdministratorTest1()
{
Criteria fakeCriteria = Isolate.Fake.Instance<Criteria>();
ResourceEnumerateClientManager fakeResourceManager = Isolate.Fake.Instance<ResourceEnumerateClientManager>();
Isolate.Swap.NextInstance<ResourceEnumerateClientManager>().With(fakeResourceManager);
Isolate.Swap.NextInstance<Criteria>().With(fakeCriteria);
List<SetResource> fakeCollection = new List<SetResource>();
Isolate.WhenCalled(() => fakeResourceManager.Enumerate<SetResource>(fakeCriteria)).WillReturn(new Collection<SetResource>());
//List<SetResource> fakeCollection = new List<SetResource>();
//Isolate.WhenCalled(() => fakeResourceManager.Enumerate<SetResource>(fakeCriteria)).WillReturnCollectionValuesOf(fakeCollection);
SecurityManager target = new SecurityManager();
PersonResource person = new PersonResource();
bool expected = false;
bool actual = target.CheckProvisioningAdministrator(person);
Assert.AreEqual(expected, actual);
}
Thanks.