public void exception_should_serialize_properly()
        {
            var firstProblem = new ConvertProblem { Property = ReflectionHelper.GetProperty<DateTime>(d => d.Month) };
            var secondProblem = new ConvertProblem { Property = 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);
        }
Beispiel #2
0
        public void LogProblem(string exceptionText, BindingValue value = null, PropertyInfo property = null)
        {
            var problem = new ConvertProblem {
                ExceptionText = exceptionText,
                Item          = Object,
                Property      = property,
                Value         = value
            };

            _problems.Add(problem);
        }
Beispiel #3
0
        public void LogProblem(string exceptionText)
        {
            var problem = new ConvertProblem()
            {
                ExceptionText = exceptionText,
                Item          = Object,
                Properties    = _propertyStack.ToArray().Reverse(),
                Value         = PropertyValue
            };

            _problems.Add(problem);
        }
        public void should_throw_bind_result_assertion_exception_on_problems()
        {
            var problem = new ConvertProblem { Property = typeof(PropertyHolder).GetProperty("SomeProperty"), Value = new BindingValue() { RawValue = "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.Property.Name
                , problem.Value, Environment.NewLine, problem.ExceptionText));
            ex.Type.ShouldEqual(typeof (string));
            ex.Problems.ShouldContain(problem);
        }
 public void SetUp()
 {
     _problem = new ConvertProblem{Item="some item", Value="some value", ExceptionText="exception message"};
     _problem.Properties = new List<PropertyInfo> {typeof (PropertyHolder).GetProperty("SomeProperty")};
 }
 public void SetUp()
 {
     _problem = new ConvertProblem { Item = "some item", Value = new BindingValue() { RawValue = "some value" }, ExceptionText = "exception message" };
     _problem.Property = typeof (PropertyHolder).GetProperty("SomeProperty");
 }