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"); }
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"); }
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); }