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;
                    }
                });
            }
        }
Пример #3
0
 public static Guid SingleId(this ReferencesFieldProperties properties)
 {
     return(properties.SchemaIds?.Count == 1 ? properties.SchemaIds[0] : Guid.Empty);
 }
Пример #4
0
 public static RootField <ReferencesFieldProperties> References(long id, string name, Partitioning partitioning, ReferencesFieldProperties properties = null)
 {
     return(new RootField <ReferencesFieldProperties>(id, name, partitioning, properties ?? new ReferencesFieldProperties()));
 }
Пример #5
0
 public static ArrayField AddReferences(this ArrayField field, long id, string name, ReferencesFieldProperties properties = null)
 {
     return(field.AddField(References(id, name, properties)));
 }
Пример #6
0
 public static Schema AddReferences(this Schema schema, long id, string name, Partitioning partitioning, ReferencesFieldProperties properties = null)
 {
     return(schema.AddField(References(id, name, partitioning, properties)));
 }
Пример #7
0
 public static NestedField <ReferencesFieldProperties> References(long id, string name, ReferencesFieldProperties properties = null)
 {
     return(new NestedField <ReferencesFieldProperties>(id, name, properties ?? new ReferencesFieldProperties()));
 }
Пример #8
0
 public static NestedField <ReferencesFieldProperties> References(long id, string name, ReferencesFieldProperties properties = null, IFieldSettings settings = null)
 {
     return(new NestedField <ReferencesFieldProperties>(id, name, properties, settings));
 }
Пример #9
0
 public static DomainId SingleId(this ReferencesFieldProperties properties)
 {
     return(properties.SchemaIds?.Count == 1 ? properties.SchemaIds[0] : default);