public void Validation_OnNoError_ReturnsValue() { var example = new ThrowMyToys(); var v = example.ValidateName("BooBoo");//returns the value if valid Assert.Equal("BooBoo", v); }
public void Validation_OnError_DoesNotReturnValue() { var example = new ThrowMyToys(); var v = example.ValidateName("FooBoo");//returns the value if valid Assert.NotEqual("FooBoo", v); }
public void Validation_OnNoError_IsValidIsTrue() { var example = new ThrowMyToys(); var v = example.ValidateName("BooBoo"); Assert.True(v.IsValid); }
public void Validation_OnInvalid_IsValidIsFalse() { var example = new ThrowMyToys(); var v = example.ValidateName("foo"); Assert.False(v.IsValid); }
public void Validation_OnError_IsValidIsFalse() { var example = new ThrowMyToys(); var v = example.ValidateName(null); Assert.False(v.IsValid); }
public void GetOrElse_OnNoError_ReturnsValue() { var example = new ThrowMyToys(); var v = example.ValidateName("BooBoo"); var result = v.GetOrElse("Bob"); Assert.Equal("BooBoo", result); }
public void Validation_OnError_ContainsErrors() { var example = new ThrowMyToys(); Validation <string> v = example.ValidateName("fooBoo"); v.Match( Invalid: errors => Assert.Equal(2, errors.Count()), Valid: str => Assert.True(false) ); }
public void GetOrElse_OnError_CallsFallback() { var result = false; Func <string> fallback = () => { result = true; return("Bob"); }; var example = new ThrowMyToys(); var v = example.ValidateName("FooBoo"); var x = v.GetOrElse(fallback); Assert.True(result); }