I'm fairly new to mocking and unit testing, so sorry if this is a simple one. I'm trying to write a unit test to make sure my login controller is working. Part of the login controller's method logic is to call the cookiehandler's save method which is below.
public void SaveCookie(Dictionary<string, string> values, string cookieName, DateTime? persistUntilDate){
//...logic here
}
So in my unit test I have this which is not compiling and I'm not sure why.
var mockCookieHandler = new Mock<ICookieHandler>();
mockCookieHandler.Verify(x => x.SaveCookie(It.IsAny<Dictionary<string, string>>(), It.IsAny<string>(), It.IsAny<DateTime>()), Times.Once);
I get the following error when trying to compile which points at the Verify line....
Error 1 The best overloaded method match for 'Moq.Mock<FAPPO.Domain.Helpers.Web.ICookieHandler>.Verify(System.Linq.Expressions.Expression<System.Action<FAPPO.Domain.Helpers.Web.ICookieHandler>>, Moq.Times)' has some invalid arguments
Error 2 Argument 2: cannot convert from 'method group' to 'Moq.Times'