public void Should_add_error_if_min_greater_than_max()
        {
            var sut = new AssetsFieldProperties {
                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 AssetsFieldProperties();

            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 NestedField <AssetsFieldProperties> Assets(long id, string name, AssetsFieldProperties properties = null)
 {
     return(new NestedField <AssetsFieldProperties>(id, name, properties ?? new AssetsFieldProperties()));
 }
예제 #4
0
 public static RootField <AssetsFieldProperties> Assets(long id, string name, Partitioning partitioning, AssetsFieldProperties properties = null)
 {
     return(new RootField <AssetsFieldProperties>(id, name, partitioning, properties ?? new AssetsFieldProperties()));
 }
예제 #5
0
 public static ArrayField AddAssets(this ArrayField field, long id, string name, AssetsFieldProperties properties = null)
 {
     return(field.AddField(Assets(id, name, properties)));
 }
예제 #6
0
 public static Schema AddAssets(this Schema schema, long id, string name, Partitioning partitioning, AssetsFieldProperties properties = null)
 {
     return(schema.AddField(Assets(id, name, partitioning, properties)));
 }
예제 #7
0
 public static NestedField <AssetsFieldProperties> Assets(long id, string name, AssetsFieldProperties properties = null, IFieldSettings settings = null)
 {
     return(new NestedField <AssetsFieldProperties>(id, name, properties, settings));
 }
예제 #8
0
 public static RootField <AssetsFieldProperties> Assets(long id, string name, Partitioning partitioning, AssetsFieldProperties properties = null, IFieldSettings settings = null)
 {
     return(new RootField <AssetsFieldProperties>(id, name, partitioning, properties, settings));
 }