Exemplo n.º 1
0
 public void CanMatchFailure()
 {
     var request = new Request { Name = "Steffen", EMail = "" };
     var result = Validation.ValidateInput(request);
     result.Match(
        (x, msgs) => { throw new Exception("wrong match case"); },
        msgs => { "Email must not be blank".ShouldBeEquivalentTo(msgs.ElementAt(0)); });
 }
Exemplo n.º 2
0
 public void CanMatchSuccess()
 {
     var request = new Request { Name = "Steffen", EMail = "*****@*****.**" };
     var result = Validation.ValidateInput(request);
     result.Match(
        (x, msgs) => { request.ShouldBeEquivalentTo(x); },
        msgs => { throw new Exception("wrong match case"); });
 }
Exemplo n.º 3
0
 public void CanCreateSuccess()
 {
     var request = new Request { Name = "Steffen", EMail = "*****@*****.**" };
     var result = Validation.ValidateInput(request);
     request.ShouldBeEquivalentTo(result.SucceededWith());
 }
Exemplo n.º 4
0
 public static Result<Request, string> ValidateInput(Request input)
 {
     if (input.Name == "")
         return Result.FailWith<Request, string>("Name must not be blank");
     if (input.EMail == "")
         return Result.FailWith<Request, string>("Email must not be blank");
     return Result.Succeed<Request, string>(input);
 }