Skip to content

Instantly share code, notes, and snippets.

@tswann
Created February 14, 2013 17:10
Show Gist options
  • Save tswann/4954348 to your computer and use it in GitHub Desktop.
Save tswann/4954348 to your computer and use it in GitHub Desktop.
[Test]
public void ShouldThrowExceptionIfOpenTaskExists()
{
Entity contact = new Entity()
{
LogicalName = "contact",
Id = Guid.NewGuid()
};
ParameterCollection parameters = new ParameterCollection();
parameters["Target"] = contact.ToEntityReference();
this.PipelineContextMock.Setup(p => p.InputParameters).Returns(parameters);
this.PipelineContextMock.Setup(p => p.MessageName).Returns("Delete");
EntityCollection tasks = new EntityCollection() { EntityName = "task", Entities = { GetRelatedTask(contact.Id) } };
this.OrganizationServiceMock.Setup(s => s.RetrieveMultiple(It.IsAny<QueryExpression>())).Returns(tasks);
PreValidateContactDelete plugin = new PreValidateContactDelete();
var exception = Assert.Throws<InvalidPluginExecutionException>(() => plugin.Execute(ServiceProviderMock.Object));
Assert.That(exception.Message, Is.StringContaining(OPEN_TASKS_EXCEPTION));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment