Skip to content

Instantly share code, notes, and snippets.

@chester89
Created February 20, 2013 11:53
Show Gist options
  • Save chester89/4995001 to your computer and use it in GitHub Desktop.
Save chester89/4995001 to your computer and use it in GitHub Desktop.
Moq setup for a method that takes base class parameter
public class when_car_was_stolen: claim_fixture
{
Because of = () =>
{
model.Risk = RiskTypes.Theft;
responsibleGuid = responsibleId;
workitemRepo.Setup(x => x.Add(MockIt.Is<SendEmailWorkItem>(wi => wi.ResponsibleId == responsibleGuid))).Verifiable();
workitemRepo.Setup(x => x.Add(MockIt.Is<WorkItem>(wi => wi.TaskType == (int)TaskTypes.CreateClaim && wi.ResponsibleId == responsibleGuid))).Verifiable();
controller.DamageClaim(model);
};
private It should_add_new_claim_workitem = () =>
{
workitemRepo.Verify(x => x.Add(MockIt.Is<WorkItem>(wi => wi.TaskType == (int)TaskTypes.CreateClaim)), Times.Once());
};
private It should_add_security_service_notification_workitem_with_same_responsible_as_new_claim = () =>
{
workitemRepo.Verify(x => x.Add(MockIt.Is<SendEmailWorkItem>(wi => wi.ResponsibleId == responsibleGuid)), Times.Once());
};
private static Guid responsibleGuid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment