Exemple #1
0
 public void LINQ_formlet_with_validation_error()
 {
     var e = new FormElements();
     var f = from name in e.Text()
             join age in e.Int() on 1 equals 1
             where age == 42
             select new { name, age };
     var r = f.Run(new Dictionary<string,string> {
         {"f0", "John"},
         {"f1", "44"},
     });
     Assert.False(r.Value.HasValue());
     Assert.Equal(1, r.Errors.Length);
 }
Exemple #2
0
 public void LINQ_formlet()
 {
     var e = new FormElements();
     var f = from name in e.Text()
             join _ in Formlet.Raw(X.E("br")) on 1 equals 1
             join age in e.Int() on 1 equals 1
             where age == 42
             select new { name, age };
     var r = f.Run(new Dictionary<string, string> {
         {"f0", "John"},
         {"f1", "42"},
     });
     Assert.True(r.Value.HasValue());
     Assert.Equal("John", r.Value.Value.name);
     Assert.Equal(42, r.Value.Value.age);
 }