コード例 #1
0
 protected ActionResult HandleViewException<T>(T model, SimpleValidationException ex)
 {
     ModelState.Clear();
     foreach (var item in ex.Errors)
         ModelState.AddModelError(item.PropertyName, item.Message);
     return View(model);
 }
コード例 #2
0
        public void TestSerializeValidationException()
        {
            var c = Customer.ListAll(1).FirstOrDefault();
            c.Should().Not.Be.Null();

            c.CompanyName = new string('0', 42);
            c.ContactName = new string('0', 42);

            var obj = new SimpleValidationException(c.Validate());
            var bytes = SimpleSerializer.Binary().Serialize(obj);
            var obj2 = SimpleSerializer.Binary().Deserialize(bytes) as SimpleValidationException;

            obj2.Errors.Count().Should().Be(obj.Errors.Count());
        }