public async void ValidateJsonStructure_WithNotNullElementAndNotGivenValueInsideJson_ShouldReturnFalse() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_city", Name = "city", DataType = DataTypeEnum.String, Nullable = false }, new Field { Id = "test_country", Name = "country", DataType = DataTypeEnum.String, Nullable = false } } }; Assert.False(await structure.ValidateJsonStructure(new { city = "Tabriz" })); }
public async void ValidateJsonStructure_WithNullableIntegerAndNotNullableStringWithWrongValue_ShouldReturnFalse() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_age", Name = "age", DataType = DataTypeEnum.Integer, Nullable = true }, new Field { Id = "test_name", Name = "name", DataType = DataTypeEnum.String, Nullable = false } } }; Assert.False(await structure.ValidateJsonStructure(new { name = "Yashar", age = "gfh" })); }
public async void ValidateJsonStructure_WithNotNullElementAndFullValueInsideJson_ShouldReturnTrue() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { Field.NotNullString("test_city", "city"), Field.NotNullString("test_country", "country") } }; Assert.True(await structure.ValidateJsonStructure(new { city = "Tabriz", country = "Iran" })); }
public async void ValidateJsonStructure_WithSimpleInteger_ShouldValidate() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_age", Name = "age", DataType = DataTypeEnum.Integer, Structure = null } } }; Assert.True(await structure.ValidateJsonStructure(new { age = 34 })); }
public async void ValidateJsonStructure_WithBase64ElementInStructureAndWrongDataInsideJson_ShouldReturnFalse() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_binary", Name = "binary", DataType = DataTypeEnum.Binary, Nullable = false } } }; Assert.False(await structure.ValidateJsonStructure(new { binary = "123" })); }
public async void ValidateJsonStructure_WithSimpleStringAndIntegerInput_ShouldNotValidate() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_name", Name = "name", DataType = DataTypeEnum.String, Structure = null } } }; Assert.False(await structure.ValidateJsonStructure(new { name = 34 })); }
public async void ValidateJsonStructure_WithTimeElementInStructureAndInsideJson_ShouldReturnTrue() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_time", Name = "time", DataType = DataTypeEnum.Time, Nullable = false } } }; Assert.True(await structure.ValidateJsonStructure(new { time = "12:30" })); }
public async void ValidateJsonStructure_WithSimpleString_ShouldValidate() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_name", Name = "name", DataType = DataTypeEnum.String, Structure = null } } }; Assert.True(await structure.ValidateJsonStructure(new { name = "Yashar" })); }
public async void ValidateJsonStructure_WithNullableInteger_ShouldReturnTrue() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_age", Name = "age", DataType = DataTypeEnum.Integer, Nullable = true, Structure = null } } }; Assert.True(await structure.ValidateJsonStructure(new { name = "Yashar" })); }
public async void ValidateJsonStructure_WithObjectInStructureAndWrongInput_ShouldReturnFalse() { var structure = new StructureDefinition { Id = "test", Fields = new List <Field> { new Field { Id = "test_address", Name = "address", DataType = DataTypeEnum.Object, Nullable = false, Structure = new StructureDefinition { Id = "address", Name = "address", Fields = new List <Field> { new Field { Id = "test_city", Name = "city", DataType = DataTypeEnum.String, Nullable = false }, new Field { Id = "test_country", Name = "country", DataType = DataTypeEnum.String, Nullable = false } } } } } }; Assert.False(await structure.ValidateJsonStructure(new { name = "Yashar", age = "gfh" })); }