tags:

views:

29

answers:

1

is it legal to MOQ a class that does not inherit an interface like so:

var mockIActionService = new Mock<IActionService>();
var mockValidAgeRule = new Mock<ValidAgeRule>(mockIActionService.Object);

I inject the IService into ValidAgeRule which is just a simple class with one method called "Excute". My question is how to I verify that has been called. Whenever I try:

mockValidAgeRule.Verify(x => x.Execute(app)); //Where App is a valid object

does anyone know how to do this?

A: 

I believe you need to make your Execute method virtual.

My understanding is that Moq creates a subclass of your class in this case, and needs to override your method in order to keep track of whether it has been called.

adrift
ya I heeded to make it virtual
jquery auth