public void When_passing_preentityimages_it_gets_added_to_context() { // arrange var context = new XrmFakedContext(); var target = new Entity(); EntityImageCollection preEntityImages = new EntityImageCollection(); preEntityImages.Add("PreImage", new Entity()); // act context.ExecutePluginWithTargetAndPreEntityImages <EntityImagesPlugin>(target, preEntityImages); // assert EntityImageCollection postImagesReturned = target["PostEntityImages"] as EntityImageCollection; if (postImagesReturned.Count > 0) { throw new Exception("PostEntityImages should not be set."); } EntityImageCollection preImagesReturned = target["PreEntityImages"] as EntityImageCollection; Assert.Equal(1, preImagesReturned?.Count); Assert.IsType(typeof(Entity), preImagesReturned["PreImage"]); }