예제 #1
0
        public void ShouldPopulateReferencesDefinedSeparately()
        {
            var contractDictionary = new CaseInsensitiveDictionary <SchemaObject>
            {
                { "Contract", new SchemaObject {
                      Type = "Object"
                  } },
                { "Custom", new SchemaObject {
                      Type = "String", Example = "Custom example"
                  } }
            };

            contractDictionary["Contract"].Properties = new CaseInsensitiveDictionary <SchemaObject>
            {
                { "Test", new SchemaObject {
                      Reference = "#/Custom"
                  } },
            };

            var result = SchemaObject.PopulateReferences(contractDictionary);

            result.HasReferenceError.ShouldBeFalse();
            result.SchemaDictionary["Contract"].Properties["Test"].Type.ShouldBe("String");
            result.SchemaDictionary["Contract"].Properties["Test"].Example.ShouldBe("Custom example");
        }
예제 #2
0
        public void ShouldHaveErrorWhenReferenceNotDefined()
        {
            var contractDictionary = new CaseInsensitiveDictionary <SchemaObject>
            {
                { "Contract", new SchemaObject {
                      Type = "Object"
                  } }
            };

            contractDictionary["Contract"].Properties = new CaseInsensitiveDictionary <SchemaObject>
            {
                { "Test", new SchemaObject {
                      Reference = "#/Custom"
                  } },
            };

            var result = SchemaObject.PopulateReferences(contractDictionary);

            result.HasReferenceError.ShouldBeTrue();
        }