public void GetPolymorphicContextShouldThrowIfManifestValueCannotHavePolymorphicTypes([ManifestModel] ManifestPolymorphicType manifestModel,
                                                                                              ValidatorBuilderContextFactory sut)
        {
            var validationContext = new ValidatorBuilderContext(manifestModel);

            Assert.That(() => sut.GetPolymorphicContext(validationContext, typeof(object)),
                        Throws.ArgumentException.And.Message.StartWith("The validation manifest value for the current context must implement IHasPolymorphicTypes"));
        }
        public void GetPolymorphicContextShouldReturnANewContextIfAnExistingPolymorphicTypeDoesNotExist([ManifestModel] ManifestValue manifestValue,
                                                                                                        ValidatorBuilderContextFactory sut)
        {
            manifestValue.PolymorphicTypes.Clear();
            var validationContext = new ValidatorBuilderContext(manifestValue);

            Assert.That(() => sut.GetPolymorphicContext(validationContext, typeof(string))?.ManifestValue,
                        Is.InstanceOf <ManifestPolymorphicType>());
        }
        public void GetPolymorphicContextShouldReturnAContextFromAnExistingPolymorphicTypeIfItExists([ManifestModel] ManifestPolymorphicType polymorphicValue,
                                                                                                     [ManifestModel] ManifestValue manifestValue,
                                                                                                     ValidatorBuilderContextFactory sut)
        {
            manifestValue.PolymorphicTypes.Add(polymorphicValue);
            polymorphicValue.ValidatedType = typeof(string);
            var validationContext = new ValidatorBuilderContext(manifestValue);

            Assert.That(() => sut.GetPolymorphicContext(validationContext, typeof(string))?.ManifestValue,
                        Is.SameAs(polymorphicValue));
        }