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 is not a Javascript property name.", "Fields[1].Name")); }
public async Task 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" }; await ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Field properties is required.", "Fields[1].Properties")); }
public async Task 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" }; await ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Field name must be a valid javascript property name.", "Fields[1].Name")); }
public async Task 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" }; await ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Partitioning is not a valid value.", "Fields[1].Partitioning")); }
public Task CanCreate_should_throw_exception_if_field_properties_not_valid() { var command = new CreateSchema { AppId = appId, Fields = new List <CreateSchemaField> { new CreateSchemaField { Name = "field1", Properties = new StringFieldProperties { MinLength = 10, MaxLength = 5 }, Partitioning = Partitioning.Invariant.Key } }, Name = "new-schema" }; return(ValidationAssert.ThrowsAsync(() => GuardSchema.CanCreate(command, appProvider), new ValidationError("Max length must be greater than min length.", "Fields[1].Properties.MinLength", "Fields[1].Properties.MaxLength"))); }
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 void CanDelete_should_not_throw_exception() { var command = new DeleteSchema(); GuardSchema.CanDelete(schema_0, command); }
public void CanChangeCategory_should_not_throw_exception() { var command = new ChangeCategory(); GuardSchema.CanChangeCategory(schema_0, command); }
public void CanUnpublish_should_throw_exception_if_already_unpublished() { var command = new UnpublishSchema(); Assert.Throws <DomainException>(() => GuardSchema.CanUnpublish(schema_0, command)); }
public void CanPublish_should_not_throw_exception_if_not_published() { var command = new PublishSchema(); GuardSchema.CanPublish(schema_0, command); }
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))); }