Exemplo n.º 1
0
        public async Task Should_not_add_error_if_geolocation_is_valid_null()
        {
            var sut = new GeolocationField(1, "my-geolocation", Partitioning.Invariant);

            await sut.ValidateAsync(CreateValue(JValue.CreateNull()), errors);

            Assert.Empty(errors);
        }
Exemplo n.º 2
0
        public async Task Should_add_errors_if_geolocation_is_required()
        {
            var sut = new GeolocationField(1, "my-geolocation", Partitioning.Invariant, new GeolocationFieldProperties {
                IsRequired = true
            });

            await sut.ValidateAsync(CreateValue(JValue.CreateNull()), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is required" });
        }
Exemplo n.º 3
0
        public async Task Should_not_add_error_if_geolocation_is_valid()
        {
            var sut = new GeolocationField(1, "my-geolocation", Partitioning.Invariant);

            var geolocation = new JObject(
                new JProperty("latitude", 0),
                new JProperty("longitude", 0));

            await sut.ValidateAsync(CreateValue(geolocation), errors);

            Assert.Empty(errors);
        }
Exemplo n.º 4
0
        public async Task Should_add_errors_if_geolocation_has_invalid_properties()
        {
            var sut = new GeolocationField(1, "my-geolocation", Partitioning.Invariant, new GeolocationFieldProperties {
                IsRequired = true
            });

            var geolocation = new JObject(
                new JProperty("latitude", 200),
                new JProperty("longitude", 0));

            await sut.ValidateAsync(CreateValue(geolocation), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not a valid value" });
        }
Exemplo n.º 5
0
        public void Should_clone_object()
        {
            var sut = new GeolocationField(1, "my-geolocation", Partitioning.Invariant);

            Assert.NotEqual(sut, sut.Enable());
        }
Exemplo n.º 6
0
        public void Should_instantiate_field()
        {
            var sut = new GeolocationField(1, "my-geolocation", Partitioning.Invariant);

            Assert.Equal("my-geolocation", sut.Name);
        }