Exemple #1
0
 public void SetUp()
 {
     _problem = new ConvertProblem {
         Item = "some item", Value = "some value", ExceptionText = "exception message"
     };
     _problem.Properties = new List <PropertyInfo> {
         typeof(PropertyHolder).GetProperty("SomeProperty")
     };
 }
        Checkbox_handling__if_the_property_type_is_boolean_and_the_value_does_not_equal_the_name_and_isnt_a_recognizeable_boolean_a_problem_should_be_attached
            ()
        {
            usingData(x => x.Data(o => o.Alive, "BOGUS"));

            ConvertProblem problem = theScenario.Problems.Single();

            problem.Property.Name.ShouldEqual("Alive");
        }
Exemple #3
0
        Checkbox_handling__if_the_property_type_is_boolean_and_the_value_does_not_equal_the_name_and_isnt_a_recognizeable_boolean_a_problem_should_be_attached
            ()
        {
            context["Alive"] = "BOGUS";
            theResult.Problems.Count.ShouldEqual(1);

            ConvertProblem problem = theResult.Problems.First();

            problem.PropertyName().ShouldEqual("Alive");
        }
Exemple #4
0
 public void SetUp()
 {
     _problem = new ConvertProblem {
         Item = "some item", Value = new BindingValue()
         {
             RawValue = "some value"
         }, ExceptionText = "exception message"
     };
     _problem.Property = typeof(PropertyHolder).GetProperty("SomeProperty");
 }
Exemple #5
0
        public void create_and_populate_should_not_throw_exception_during_type_conversion_and_return_a_meaningful_error()
        {
            context["Age"] = "abc";
            theResultingObject.Age.ShouldEqual(default(int));
            theResult.Problems.Count.ShouldEqual(1);

            ConvertProblem problem = theResult.Problems.First();

            problem.ExceptionText.ShouldContain("FormatException");
            problem.Item.ShouldBeTheSameAs(theResultingObject);
            problem.PropertyName().ShouldEqual("Age");
            problem.Value.ShouldEqual("abc");
        }
Exemple #6
0
        public void exception_should_serialize_properly()
        {
            var firstProblem = new ConvertProblem {
                Properties = new[] { ReflectionHelper.GetProperty <DateTime>(d => d.Month) }
            };
            var secondProblem = new ConvertProblem {
                Properties = new[] { ReflectionHelper.GetProperty <DateTime>(d => d.Day) }
            };
            var originalException = new BindResultAssertionException(typeof(string), new[] { firstProblem, secondProblem });

            var deserializedException = originalException.ShouldTransferViaSerialization();

            deserializedException.Type.ShouldEqual(originalException.Type);
            deserializedException.Problems.ShouldHaveCount(originalException.Problems.Count);
        }
Exemple #7
0
        public void should_throw_bind_result_assertion_exception_on_problems()
        {
            var problem = new ConvertProblem {
                Properties = new List <PropertyInfo> {
                    typeof(PropertyHolder).GetProperty("SomeProperty")
                }, Value = "some value"
            };

            result.Problems.Add(problem);

            var ex = typeof(BindResultAssertionException).ShouldBeThrownBy(
                () => result.AssertNoProblems(typeof(string))) as BindResultAssertionException;

            ex.ShouldNotBeNull();
            ex.Message.ShouldEqual("Failure while trying to bind object of type '{0}'".ToFormat(ex.Type) +
                                   "Property: {0}, Value: '{1}', Exception:{2}{3}{2}".ToFormat(problem.PropertyName()
                                                                                               , problem.Value, Environment.NewLine, problem.ExceptionText));
            ex.Type.ShouldEqual(typeof(string));
            ex.Problems.ShouldContain(problem);
        }