Beispiel #1
0
        public void Should_add_error_if_editor_is_not_valid()
        {
            var sut = new GeolocationFieldProperties {
                Editor = (GeolocationFieldEditor)123
            };

            sut.Validate(errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Editor is not a valid value", "Editor")
            });
        }
Beispiel #2
0
        public void Should_set_or_freeze_sut()
        {
            var sut = new GeolocationFieldProperties();

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