Beispiel #1
0
        public void returns_default_value_for_properties_marked_with_optional_attribute()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.Null(result.String);
        }
Beispiel #2
0
        public void bool_always_defaults_to_false_on_relaxed_types_if_not_present()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.Equal(false, result.Bool);
        }
Beispiel #3
0
        public void bool_is_optional_on_strict_types_and_defaults_to_false_if_not_present()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (StrictArgument)sut.Map(typeof(StrictArgument), new[] { new Argument("text", "foo") });

            Assert.Equal(false, result.Bool);
        }
Beispiel #4
0
        public void can_map_simple_bool_to_false()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("bool", "false") });

            Assert.Equal(false, result.Bool);
        }
Beispiel #5
0
        public void bool_always_defaults_to_true_if_present_and_has_empty_value()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("bool", "") });

            Assert.Equal(true, result.Bool);
        }
Beispiel #6
0
        public void can_map_simple_string()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("string", "foo") });

            Assert.Equal("foo", result.String);
        }
Beispiel #7
0
        public void returns_expected_type()
        {
            var sut    = new DefaultArgumentMapper();
            var result = sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.IsAssignableFrom <RelaxedArgument>(result);
        }
Beispiel #8
0
        public void can_map_simple_char()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("char", "A") });

            Assert.Equal('A', result.Char);
        }
Beispiel #9
0
        public void can_map_simple_decimal()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("decimal", "1.23") });

            Assert.Equal(1.23M, result.Decimal);
        }
Beispiel #10
0
        public void can_map_simple_float()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("float", "1.23") });

            Assert.Equal(1.23f, result.Float);
        }
Beispiel #11
0
        public void can_use_a_try_parse_method_by_convention()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (CustomValueTypeArgument)sut.Map(typeof(CustomValueTypeArgument), new[] { new Argument("id", "1"), });

            Assert.Equal(1, result.Id.Value);
        }
Beispiel #12
0
        public void can_map_simple_ushort()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("ushort", "1") });

            Assert.Equal(1, result.UShort);
        }
Beispiel #13
0
        public void returns_instance()
        {
            var sut    = new DefaultArgumentMapper();
            var result = sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.NotNull(result);
        }
        public void can_map_simple_bool_to_true()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("bool", "true") });

            Assert.Equal(true, result.Bool);
        }
        public void can_map_simple_char()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("char", "A") });

            Assert.Equal('A', result.Char);
        }
        public void can_map_simple_byte()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("byte", "1") });

            Assert.Equal(1, result.Byte);
        }
        public void bool_always_defaults_to_false_on_relaxed_types_if_not_present()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.Equal(false, result.Bool);
        }
        public void bool_always_defaults_to_true_if_present_and_has_empty_value()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("bool", "") });

            Assert.Equal(true, result.Bool);
        }
Beispiel #19
0
        public void can_map_simple_ulong()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("ulong", "1") });

            Assert.Equal((ulong)1, result.ULong);
        }
        public void bool_is_optional_on_strict_types_and_defaults_to_false_if_not_present()
        {
            var sut = new DefaultArgumentMapper();
            var result = (StrictArgument) sut.Map(typeof (StrictArgument), new[] {new Argument("text", "foo")});

            Assert.Equal(false, result.Bool);
        }
Beispiel #21
0
        public void can_map_simple_sbyte()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("sbyte", "1") });

            Assert.Equal(1, result.SByte);
        }
Beispiel #22
0
        public void can_map_simple_guid()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("guid", "D29F1B98-00F4-49D9-AFF8-87755859B702"), });

            Assert.Equal(new Guid("D29F1B98-00F4-49D9-AFF8-87755859B702"), result.Guid);
        }
Beispiel #23
0
        public void can_map_simple_long_datetime()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("datetime", "2000-01-01 01:02:03"), });

            Assert.Equal(new DateTime(2000, 1, 1, 1, 2, 3), result.DateTime);
        }
Beispiel #24
0
        public void can_use_simple_constructor_with_a_simple_primitive()
        {
            var sut    = new DefaultArgumentMapper();
            var result = (SimpleConstructorArgument)sut.Map(typeof(SimpleConstructorArgument), new[] { new Argument("id", "1"), });

            Assert.Equal(1, result.Id.Value);
        }
        public void can_map_simple_decimal()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("decimal", "1.23") });

            Assert.Equal(1.23M, result.Decimal);
        }
Beispiel #26
0
        public void can_map_nullable_int()
        {
            var expected = 1;

            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedNullableArgument)sut.Map(typeof(RelaxedNullableArgument), new[] { new Argument("nullableint", expected.ToString()) });

            Assert.Equal(expected, result.NullableInt);
            Assert.Equal(expected, result.NullableInt.Value);
        }
Beispiel #27
0
        public void can_map_nullable_guid()
        {
            var expected = Guid.NewGuid();

            var sut    = new DefaultArgumentMapper();
            var result = (RelaxedNullableArgument)sut.Map(typeof(RelaxedNullableArgument), new[] { new Argument("nullableguid", expected.ToString("N")) });

            Assert.Equal(expected, result.NullableGuid);
            Assert.Equal(expected, result.NullableGuid.Value);
        }
        public void can_map_simple_guid()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("guid", "D29F1B98-00F4-49D9-AFF8-87755859B702"), });

            Assert.Equal(new Guid("D29F1B98-00F4-49D9-AFF8-87755859B702"), result.Guid);
        }
        public void can_map_simple_string()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("string", "foo") });

            Assert.Equal("foo", result.String);
        }
        public void returns_instance()
        {
            var sut = new DefaultArgumentMapper();
            var result = sut.Map(typeof (RelaxedArgument), new Argument[0]);

            Assert.NotNull(result);
        }
 public void throws_exception_if_required_property_is_missing_a_value()
 {
     var sut = new DefaultArgumentMapper();
     Assert.Throws<Exception>(() => sut.Map(typeof (StrictArgument), new Argument[0]));
 }
        public void returns_expected_type()
        {
            var sut = new DefaultArgumentMapper();
            var result = sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.IsAssignableFrom<RelaxedArgument>(result);
        }
        public void returns_default_value_for_properties_marked_with_optional_attribute()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new Argument[0]);

            Assert.Null(result.String);
        }
        public void can_map_simple_short_datetime()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("datetime", "2000-01-01"), });

            Assert.Equal(new DateTime(2000, 1, 1), result.DateTime);
        }
        public void can_use_simple_constructor_with_a_simple_primitive()
        {
            var sut = new DefaultArgumentMapper();
            var result = (SimpleConstructorArgument)sut.Map(typeof(SimpleConstructorArgument), new[] { new Argument("id", "1"), });

            Assert.Equal(1, result.Id.Value);
        }
        public void can_use_a_try_parse_method_by_convention()
        {
            var sut = new DefaultArgumentMapper();
            var result = (CustomValueTypeArgument)sut.Map(typeof(CustomValueTypeArgument), new[] { new Argument("id", "1"), });

            Assert.Equal(1, result.Id.Value);
        }
        public void can_map_simple_ulong()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("ulong", "1") });

            Assert.Equal((ulong) 1, result.ULong);
        }
        public void can_map_simple_ushort()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("ushort", "1") });

            Assert.Equal(1, result.UShort);
        }
        public void can_map_simple_float()
        {
            var sut = new DefaultArgumentMapper();
            var result = (RelaxedArgument)sut.Map(typeof(RelaxedArgument), new[] { new Argument("float", "1.23") });

            Assert.Equal(1.23f, result.Float);
        }
Beispiel #40
0
        public void throws_exception_if_required_property_is_missing_a_value()
        {
            var sut = new DefaultArgumentMapper();

            Assert.Throws <Exception>(() => sut.Map(typeof(StrictArgument), new Argument[0]));
        }