Example #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 => { Assert.AreEqual("Email must not be blank", msgs[0]); });
 }
Example #2
0
 public void CanMatchSuccess()
 {
     var request = new Request { Name = "Steffen", EMail = "*****@*****.**" };
     var result = Validation.ValidateInput(request);
     result.Match(
        (x, msgs) => { Assert.AreEqual(request, x); },
        msgs => { throw new Exception("wrong match case"); });
 }
Example #3
0
        public static Result<Request, string> ValidateInput(Request input)
        {
            if (input.Name == "")
                return Result<Request, string>.FailWith("Name must not be blank");
            if (input.EMail == "")
                return Result<Request, string>.FailWith("Email must not be blank");
            return Result<Request, string>.Succeed(input);

        }
Example #4
0
 public void CanCreateSuccess()
 {
     var request = new Request { Name = "Steffen", EMail = "*****@*****.**" };
     var result = Validation.ValidateInput(request);
     Assert.AreEqual(request, result.SucceededWith());
 }