コード例 #1
0
        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")
            });
        }
コード例 #2
0
        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
ファイル: SchemaExtensions.cs プロジェクト: julienM77/squidex
 public static DomainId SingleId(this ReferencesFieldProperties properties)
 {
     return(properties.SchemaIds?.Count == 1 ? properties.SchemaIds[0] : default);