/// <summary>
        /// Checks the Pre/Post Entity Images to determine if the image collections contains an image with the given given key, that contains the attributes
        /// </summary>
        /// <param name="imageName"></param>
        /// <param name="attributeNames"></param>
        public void AssertEntityImageAttributesRegistered(string imageName, params string[] attributeNames)
        {
            Entity image;
            var    imageCollection = InvalidPluginStepRegistrationException.ImageCollection.Pre;

            if (PluginExecutionContext.PostEntityImages.TryGetValue(imageName, out image))
            {
                imageCollection = InvalidPluginStepRegistrationException.ImageCollection.Post;
            }
            else
            {
                PluginExecutionContext.PreEntityImages.TryGetValue(imageName, out image);
            }

            if (image == null)
            {
                throw InvalidPluginStepRegistrationException.ImageMissing(imageName);
            }

            var missingAttributes = attributeNames.Where(attribute => !image.Contains(attribute)).ToList();

            if (!missingAttributes.Any())
            {
                return;
            }

            throw InvalidPluginStepRegistrationException.ImageMissingRequiredAttributes(imageCollection, imageName, missingAttributes);
        }
Example #2
0
        /// <summary>
        /// Checks the Pre/Post Entity Images to determine if the the collection contains an image with the given key.
        /// Throws an exception if the image name is contained in both the Pre and Post Image.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="imageName">Name of the image.</param>
        public static void AssertEntityImageRegistered(this IPluginExecutionContext context, string imageName)
        {
            var pre  = context.PreEntityImages.ContainsKey(imageName);
            var post = context.PostEntityImages.ContainsKey(imageName);

            if (pre && post)
            {
                throw new Exception($"Both Preimage and Post Image Contain the Image \"{imageName}\".  Unable to determine what entity collection to search for the given attributes.");
            }

            if (!pre && !post)
            {
                throw InvalidPluginStepRegistrationException.ImageMissing(imageName);
            }
        }
Example #3
0
        /// <summary>
        /// Checks the Pre/Post Entity Images to determine if the image collections contains an image with the given key, that contains the attributes.
        /// Throws an exception if the image name is contained in both the Pre and Post Image.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="imageName">Name of the image.</param>
        /// <param name="attributeNames">The attribute names.</param>
        public static void AssertEntityImageAttributesExist(this IPluginExecutionContext context, string imageName, params string[] attributeNames)
        {
            AssertEntityImageRegistered(context, imageName);
            var imageCollection = context.PreEntityImages.TryGetValue(imageName, out Entity preImage) ?
                                  InvalidPluginStepRegistrationException.ImageCollection.Pre :
                                  InvalidPluginStepRegistrationException.ImageCollection.Post;

            context.PostEntityImages.TryGetValue(imageName, out Entity postImage);

            var image             = preImage ?? postImage;
            var missingAttributes = attributeNames.Where(attribute => !image.Contains(attribute)).ToList();

            if (missingAttributes.Any())
            {
                throw InvalidPluginStepRegistrationException.ImageMissingRequiredAttributes(imageCollection, imageName, missingAttributes);
            }
        }