-1

I try to remove data by using the method above

public virtual void ClearOrderTypeCache()
{
    orderTypeList = null;
    cacheService.Set<OrderTypeProjection[]>(orderTypeCacheKey, null);
}

But I've got an exception when I try to use it

ICacheService.Set<OrderTypeProjection[]>("189b5a92-e728-405a-b13a-e3b62c870845-OrderTypes", null) 
invocation failed with mock behavior Strict.
All invocations on the mock must have a corresponding setup.'
tym32167
  • 4,741
  • 2
  • 28
  • 32
Sergiu
  • 15
  • 1
  • 4

1 Answers1

0

I hope this will help.

You are creating a Mock<>, which uses MockBehavior.Strict by default which

MockBehavior.Strict : Causes the mock to always throw an exception for invocations that don't have a corresponding setup.

Somewhere in your code you are invoking members that have no setup configured. I suggest create a setup for all members you intend to invoke during your tests

like this:

var httpStatusCode = System.Net.HttpStatusCode.BadRequest;//or what ever you want it to be
responseMessage.Setup(m => m.StatusCode).Returns(httpStatusCode);
responseMessage.Setup(m => m.ReadContentAsString()).Returns("Put your return string here");
Ghulam Mohayudin
  • 1,093
  • 10
  • 18