Pergunta

I'm trying to assert the following was called

cacheManager.Site[typeName] = items.Where(x => !requestContext.DefaultSites.Contains(x.SiteId)).ToList();

and I can't work out the syntax for indexers with args, I have this

manager.Site.AssertWasCalled(x => x[TypeName] = Arg<IList<FcCacheObject>>.Matches(y => y.Count.Equals(1)));

but its asking for the indexer to use args as well, how do I do this?

Foi útil?

Solução

It's pretty simple :)

I assume your indexer parameter type is string. Then in assertion instead of

x[TypeName]

use

x[Arg<string>.Is.Equal(TypeName)]

As result your assert should look:

manager.Site.AssertWasCalled(x => x[Arg<string>.Is.Equal(TypeName)] = Arg<IList<FcCacheObject>>.Matches(y => y.Count.Equals(1)));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top