public void Should_add_error_if_min_greater_than_max() { var sut = new ReferencesFieldProperties { MinItems = 10, MaxItems = 5 }; sut.Validate(errors); errors.ShouldBeEquivalentTo( new List <ValidationError> { new ValidationError("Max items must be greater than min items", "MinItems", "MaxItems") }); }
public void Should_set_or_freeze_sut() { var sut = new ReferencesFieldProperties(); foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) { var value = property.PropertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(property.PropertyType) : null; property.SetValue(sut, value); var result = property.GetValue(sut); Assert.Equal(value, result); } sut.Freeze(); foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) { var value = property.PropertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(property.PropertyType) : null; Assert.Throws <InvalidOperationException>(() => { try { property.SetValue(sut, value); } catch (Exception ex) { throw ex.InnerException; } }); } }
public static Guid SingleId(this ReferencesFieldProperties properties) { return(properties.SchemaIds?.Count == 1 ? properties.SchemaIds[0] : Guid.Empty); }
public static RootField <ReferencesFieldProperties> References(long id, string name, Partitioning partitioning, ReferencesFieldProperties properties = null) { return(new RootField <ReferencesFieldProperties>(id, name, partitioning, properties ?? new ReferencesFieldProperties())); }
public static ArrayField AddReferences(this ArrayField field, long id, string name, ReferencesFieldProperties properties = null) { return(field.AddField(References(id, name, properties))); }
public static Schema AddReferences(this Schema schema, long id, string name, Partitioning partitioning, ReferencesFieldProperties properties = null) { return(schema.AddField(References(id, name, partitioning, properties))); }
public static NestedField <ReferencesFieldProperties> References(long id, string name, ReferencesFieldProperties properties = null) { return(new NestedField <ReferencesFieldProperties>(id, name, properties ?? new ReferencesFieldProperties())); }
public static NestedField <ReferencesFieldProperties> References(long id, string name, ReferencesFieldProperties properties = null, IFieldSettings settings = null) { return(new NestedField <ReferencesFieldProperties>(id, name, properties, settings)); }
public static DomainId SingleId(this ReferencesFieldProperties properties) { return(properties.SchemaIds?.Count == 1 ? properties.SchemaIds[0] : default);