Ejemplo n.º 1
0
        public void TryCreateFor_CreatesAnInstance_ForDateTimeSchemaAndValue()
        {
            var schema = new OpenApiSchema {
                Type = "string", Format = "date-time"
            };

            OpenApiAnyFactory.TryCreateFor(schema, DateTime.UtcNow, out IOpenApiAny instance);

            Assert.NotNull(instance);
            Assert.IsType(typeof(OpenApiDate), instance);
        }
Ejemplo n.º 2
0
        public void TryCreateFor_CreatesAnInstance_ForDoubleSchemaAndValueWhenGivenDecimal()
        {
            var schema = new OpenApiSchema {
                Type = "number", Format = "double"
            };

            OpenApiAnyFactory.TryCreateFor(schema, 3.4m, out IOpenApiAny instance);

            Assert.NotNull(instance);
            Assert.IsType <OpenApiDouble>(instance);
        }
Ejemplo n.º 3
0
        public void TryCreateFor_CreatesAnInstance_ForProvidedSchemaAndValue(
            string schemaType,
            string schemaFormat,
            object value,
            Type expectedInstanceType)
        {
            var schema = new OpenApiSchema {
                Type = schemaType, Format = schemaFormat
            };

            OpenApiAnyFactory.TryCreateFor(schema, value, out IOpenApiAny instance);

            Assert.NotNull(instance);
            Assert.IsType(expectedInstanceType, instance);
        }