public void CanDisable_should_throw_exception_if_not_found() { var command = new DisableField { FieldId = 3 }; Assert.Throws <DomainObjectNotFoundException>(() => GuardSchemaField.CanDisable(schema_0, command)); }
public void CanDisable_should_throw_exception_if_ui_field() { var command = new DisableField { FieldId = 4 }; Assert.Throws <DomainException>(() => GuardSchemaField.CanDisable(command, schema_0)); }
public SchemaDomainObject DisableField(DisableField command) { VerifyCreatedAndNotDeleted(); RaiseEvent(command, new FieldDisabled()); return(this); }
public void CanDisable_Should_not_throw_exception_if_enabled() { var command = new DisableField { FieldId = 1 }; GuardSchemaField.CanDisable(schema_0, command); }
protected Task On(DisableField command, CommandContext context) { return(handler.UpdateSyncedAsync <SchemaDomainObject>(context, s => { GuardSchemaField.CanDisable(s.Snapshot.SchemaDef, command); s.DisableField(command); })); }
public void CanDisable_should_throw_exception_if_already_disabled() { var command = new DisableField { FieldId = 1 }; var schema_1 = schema_0.DisableField(1); Assert.Throws <DomainException>(() => GuardSchemaField.CanDisable(schema_1, command)); }
public async Task <IActionResult> DisableNestedField(string app, string name, long parentId, long id) { var command = new DisableField { ParentFieldId = parentId, FieldId = id }; var response = await InvokeCommandAsync(app, command); return(Ok(response)); }
public void CanDisable_should_throw_exception_if_already_disabled() { var command = new DisableField { FieldId = 1 }; schema.FieldsById[1].Disable(); Assert.Throws <DomainException>(() => GuardSchemaField.CanDisable(schema, command)); }
public void CanDisable_should_throw_exception_if_locked() { var command = new DisableField { FieldId = 1 }; var schema_1 = schema_0.UpdateField(1, f => f.Lock()); Assert.Throws <DomainException>(() => GuardSchemaField.CanDisable(command, schema_1)); }
public void CanDisable_should_not_throw_exception_if_already_disabled() { var command = new DisableField { FieldId = 1 }; var schema_1 = schema_0.UpdateField(1, f => f.Disable()); GuardSchemaField.CanDisable(command, schema_1); }
public async Task <IActionResult> DisableField(string app, string name, long id) { var command = new DisableField { FieldId = id }; await CommandBus.PublishAsync(command); return(NoContent()); }
public async Task <IActionResult> DisableField(string app, string name, long id) { var command = new DisableField { FieldId = id }; var response = await InvokeCommandAsync(command); return(Ok(response)); }
public static void CanDisable(DisableField command, Schema schema) { Guard.NotNull(command, nameof(command)); var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); if (!field.IsForApi(true)) { throw new DomainException(T.Get("schemas.uiFieldCannotBeDisabled")); } }
public static void CanDisable(Schema schema, DisableField command) { Guard.NotNull(command, nameof(command)); var field = GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); if (field.IsDisabled) { throw new DomainException("Schema field is already disabled."); } }
public static void CanDisable(DisableField command, Schema schema) { Guard.NotNull(command); var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); if (!field.IsForApi(true)) { throw new DomainException("UI field cannot be diabled."); } }
public SchemaDomainObject DisableField(DisableField command) { Guard.NotNull(command, nameof(command)); VerifyCreatedAndNotDeleted(); SchemaFieldGuard.GuardCanDisable(schema, command.FieldId); RaiseEvent(command, new FieldDisabled()); return(this); }
public async Task DisableField_should_create_events_and_update_state() { var command = new DisableField { FieldId = 1 }; await ExecuteCreateAsync(); await ExecuteAddFieldAsync(fieldName); var result = await sut.ExecuteAsync(CreateCommand(command)); result.ShouldBeEquivalent(sut.Snapshot); Assert.True(GetField(1).IsDisabled); LastEvents .ShouldHaveSameEvents( CreateEvent(new FieldDisabled { FieldId = fieldId }) ); }
public async Task DisableField_should_create_events_and_update_state_for_array() { var command = new DisableField { ParentFieldId = 1, FieldId = 2 }; await ExecuteCreateAsync(); await ExecuteAddArrayFieldAsync(); await ExecuteAddFieldAsync(fieldName, 1); var result = await sut.ExecuteAsync(CreateCommand(command)); result.ShouldBeEquivalent(sut.Snapshot); Assert.True(GetNestedField(1, 2).IsDisabled); LastEvents .ShouldHaveSameEvents( CreateEvent(new FieldDisabled { ParentFieldId = arrayId, FieldId = nestedId }) ); }
public void DisableField(DisableField command) { RaiseEvent(command, new FieldDisabled()); }
private void DisableField(DisableField command) { Raise(command, new FieldDisabled()); }
protected Task On(DisableField command, CommandContext context) { return(handler.UpdateAsync <SchemaDomainObject>(context, s => s.DisableField(command))); }