public Task CanCreate_should_throw_exception_if_nested_field_properties_null() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = "nested1", Properties = null } } } }, Name = "new-schema" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Field properties is required.", "Fields[1].Nested[1].Properties"))); }
public Task CanCreate_should_throw_exception_if_nested_field_have_duplicate_names() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = "nested1", Properties = new StringFieldProperties() }, new CreateSchemaNestedField { Name = "nested1", Properties = new StringFieldProperties() } } } }, Name = "new-schema" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Fields cannot have duplicate names.", "Fields[1].Nested"))); }
public Task CanCreate_should_throw_exception_if_nested_field_properties_not_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = "nested1", Properties = new StringFieldProperties { MinLength = 10, MaxLength = 5 } } } } }, Name = "new-schema" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Max length must be greater than min length.", "Fields[1].Nested[1].Properties.MinLength", "Fields[1].Nested[1].Properties.MaxLength"))); }
public void CanCreate_should_throw_exception_if_ui_field_is_invalid() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "field1", Properties = new UIFieldProperties { IsListField = true, IsReferenceField = true }, IsHidden = true, IsDisabled = true, Partitioning = Partitioning.Invariant.Key } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("UI field cannot be a list field.", "Fields[1].Properties.IsListField"), new ValidationError("UI field cannot be a reference field.", "Fields[1].Properties.IsReferenceField"), new ValidationError("UI field cannot be hidden.", "Fields[1].IsHidden"), new ValidationError("UI field cannot be disabled.", "Fields[1].IsDisabled")); }
public void CanCreate_should_throw_exception_if_nested_field_is_array() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, Nested = new List <UpsertSchemaNestedField> { new UpsertSchemaNestedField { Name = "nested1", Properties = new ArrayFieldProperties() } } } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Nested field cannot be array fields.", "Fields[1].Nested[1].Properties")); }
public void CanCreate_should_throw_exception_if_fields_contains_duplicate_name() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties(), Partitioning = Partitioning.Invariant.Key }, new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties(), Partitioning = Partitioning.Invariant.Key } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Fields cannot have duplicate names.", "Fields")); }
public Task CanCreate_should_throw_exception_if_nested_field_name_invalid() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "array", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = "invalid name", Properties = new StringFieldProperties() } } } }, Name = "new-schema" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Field name must be a valid javascript property name.", "Fields[1].Nested[1].Name"))); }
public Task CanCreate_should_throw_exception_if_fields_contain_duplicate_names() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "field1", Properties = ValidProperties(), Partitioning = "invariant" }, new CreateSchemaField { Name = "field1", Properties = ValidProperties(), Partitioning = "invariant" } }, Name = "new-schema" }; return(Assert.ThrowsAsync <ValidationException>(() => GuardSchema.CanCreate(command, appProvider))); }
public Task CanCreate_should_not_throw_exception_if_command_is_valid() { var command = new CreateSchema { AppId = appId, Name = "new-schema" }; return(GuardSchema.CanCreate(command, appProvider)); }
public Task CanCreate_should_throw_exception_if_name_not_valid() { var command = new CreateSchema { AppId = appId, Name = "INVALID NAME" }; return(Assert.ThrowsAsync <ValidationException>(() => GuardSchema.CanCreate(command, appProvider))); }
public void CanCreate_should_throw_exception_if_name_not_valid() { var command = new CreateSchema { AppId = appId, Name = "INVALID NAME" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Name is not a valid slug.", "Name")); }
public Task CanCreate_should_throw_exception_if_name_not_valid() { var command = new CreateSchema { AppId = appId, Name = "INVALID NAME" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Name is not a valid slug.", "Name"))); }
public Task CanCreate_should_throw_exception_if_name_already_in_use() { var command = new CreateSchema { AppId = appId, Name = "existing" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("A schema with the same name already exists."))); }
public Task CanCreate_should_throw_exception_if_name_already_in_use() { A.CallTo(() => appProvider.GetSchemaAsync(A <Guid> .Ignored, "new-schema")) .Returns(Task.FromResult(A.Fake <ISchemaEntity>())); var command = new CreateSchema { AppId = appId, Name = "new-schema" }; return(Assert.ThrowsAsync <ValidationException>(() => GuardSchema.CanCreate(command, appProvider))); }
public void CanCreate_should_not_throw_exception_if_command_is_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties { IsListField = true }, IsHidden = true, IsDisabled = true, Partitioning = Partitioning.Invariant.Key }, new UpsertSchemaField { Name = "field2", Properties = ValidProperties(), Partitioning = Partitioning.Invariant.Key }, new UpsertSchemaField { Name = "field3", Properties = new ArrayFieldProperties(), Partitioning = Partitioning.Invariant.Key, Nested = new List <UpsertSchemaNestedField> { new UpsertSchemaNestedField { Name = "nested1", Properties = ValidProperties() }, new UpsertSchemaNestedField { Name = "nested2", Properties = ValidProperties() } } } }, Name = "new-schema" }; GuardSchema.CanCreate(command); }
public Task CanCreate_should_not_throw_exception_if_command_is_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "field1", Properties = ValidProperties(), Partitioning = "invariant" }, new CreateSchemaField { Name = "field2", Properties = ValidProperties(), Partitioning = "invariant" }, new CreateSchemaField { Name = "field3", Properties = new ArrayFieldProperties(), Partitioning = "invariant", Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = "nested1", Properties = ValidProperties() }, new CreateSchemaNestedField { Name = "nested2", Properties = ValidProperties() } } } }, Name = "new-schema" }; return(GuardSchema.CanCreate(command, appProvider)); }
public void CanCreate_should_throw_exception_if_field_properties_null() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "field1", Properties = null, Partitioning = Partitioning.Invariant.Key } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Field properties is required.", "Fields[1].Properties")); }
public Task CanCreate_should_throw_exception_if_field_partitioning_not_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "field1", Properties = new StringFieldProperties(), Partitioning = "INVALID" } }, Name = "new-schema" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Field partitioning is not valid.", "Fields[1].Partitioning"))); }
public void CanCreate_should_throw_exception_if_field_partitioning_not_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties(), Partitioning = "INVALID" } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Partitioning is not a valid value.", "Fields[1].Partitioning")); }
public void CanCreate_should_throw_exception_if_field_name_invalid() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "invalid name", Properties = new StringFieldProperties(), Partitioning = Partitioning.Invariant.Key } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Field name must be a valid javascript property name.", "Fields[1].Name")); }
public void CanCreate_should_throw_exception_if_field_properties_not_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <UpsertSchemaField> { new UpsertSchemaField { Name = "field1", Properties = new StringFieldProperties { MinLength = 10, MaxLength = 5 }, Partitioning = Partitioning.Invariant.Key } }, Name = "new-schema" }; ValidationAssert.Throws(() => GuardSchema.CanCreate(command), new ValidationError("Max length must be greater or equal to min length.", "Fields[1].Properties.MinLength", "Fields[1].Properties.MaxLength")); }
public Task CanCreate_should_throw_exception_if_fields_not_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = null, Properties = null, Partitioning = "invalid" }, new CreateSchemaField { Name = null, Properties = InvalidProperties(), Partitioning = "invalid" }, new CreateSchemaField { Name = null, Properties = new ArrayFieldProperties(), Partitioning = "invalid", Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = null, Properties = InvalidProperties() }, new CreateSchemaNestedField { Name = null, Properties = InvalidProperties() } } }, new CreateSchemaField { Name = null, Properties = InvalidProperties(), Partitioning = "invalid", Nested = new List <CreateSchemaNestedField> { new CreateSchemaNestedField { Name = null, Properties = InvalidProperties() }, new CreateSchemaNestedField { Name = null, Properties = InvalidProperties() } } } }, Name = "new-schema" }; return(Assert.ThrowsAsync <ValidationException>(() => GuardSchema.CanCreate(command, appProvider))); }