public void Should_update_schema() { var properties = new SchemaProperties { Hints = "my-hint", Label = "my-label" }; sut = sut.Update(properties); Assert.Equal(properties, sut.Properties); }
public Schema(string name, Field[] fields, SchemaProperties properties, bool isPublished) : this(name, properties) { Guard.NotNullOrEmpty(name, nameof(name)); Guard.NotNull(fields, nameof(fields)); this.isPublished = isPublished; fieldsOrdered = ImmutableArray.Create(fields); }
public Schema Update(SchemaProperties newProperties) { Guard.NotNull(newProperties, nameof(newProperties)); return(Clone(clone => { clone.properties = newProperties; clone.properties.Freeze(); })); }
public Schema(string name, SchemaProperties?properties = null, bool isSingleton = false) { Guard.NotNullOrEmpty(name); this.name = name; this.properties = properties ?? new SchemaProperties(); this.properties.Freeze(); this.isSingleton = isSingleton; }
public static Schema Create(string name, SchemaProperties newProperties) { if (!name.IsSlug()) { var error = new ValidationError("Name must be a valid slug", "Name"); throw new ValidationException("Cannot create a new schema", error); } return(new Schema(name, false, newProperties, ImmutableList <Field> .Empty)); }
public void Should_instantiate_field() { var properties = new SchemaProperties { Hints = "my-hint", Label = "my-label" }; var schema = Schema.Create("my-name", properties); Assert.Equal("my-name", schema.Name); Assert.Equal(properties, schema.Properties); }
public Schema Update(SchemaProperties newProperties) { newProperties ??= new SchemaProperties(); if (properties.Equals(newProperties)) { return(this); } return(Clone(clone => { clone.properties = newProperties; clone.Properties.Freeze(); })); }
public Schema(string name, bool isPublished, SchemaProperties properties, ImmutableList <Field> fields) { Guard.NotNull(fields, nameof(fields)); Guard.NotNull(properties, nameof(properties)); Guard.ValidSlug(name, nameof(name)); fieldsById = fields.ToImmutableDictionary(x => x.Id); fieldsByName = fields.ToImmutableDictionary(x => x.Name, StringComparer.OrdinalIgnoreCase); this.name = name; this.fields = fields; this.properties = properties; this.properties.Freeze(); this.isPublished = isPublished; }
public bool DeepEquals(SchemaProperties properties) { return(this.WithDeepEqual(properties).IgnoreProperty <Freezable>(x => x.IsFrozen).Compare()); }
public void Update(SchemaProperties newProperties) { Guard.NotNull(newProperties, nameof(newProperties)); properties = newProperties; }
public Schema Update(SchemaProperties newProperties) { Guard.NotNull(newProperties, nameof(newProperties)); return(new Schema(name, isPublished, newProperties, fields)); }
public bool DeepEquals(SchemaProperties properties) { return(SimpleEquals.IsEquals(this, properties)); }
public static Schema Create(string name, SchemaProperties newProperties) { return(new Schema(name, false, newProperties, ImmutableList <Field> .Empty)); }