Exemple #1
0
        public void Validation_OnNoError_ReturnsValue()
        {
            var example = new ThrowMyToys();
            var v       = example.ValidateName("BooBoo");//returns the value if valid

            Assert.Equal("BooBoo", v);
        }
Exemple #2
0
        public void Validation_OnError_DoesNotReturnValue()
        {
            var example = new ThrowMyToys();
            var v       = example.ValidateName("FooBoo");//returns the value if valid

            Assert.NotEqual("FooBoo", v);
        }
Exemple #3
0
        public void Validation_OnNoError_IsValidIsTrue()
        {
            var example = new ThrowMyToys();
            var v       = example.ValidateName("BooBoo");

            Assert.True(v.IsValid);
        }
Exemple #4
0
        public void Validation_OnInvalid_IsValidIsFalse()
        {
            var example = new ThrowMyToys();
            var v       = example.ValidateName("foo");

            Assert.False(v.IsValid);
        }
Exemple #5
0
        public void Validation_OnError_IsValidIsFalse()
        {
            var example = new ThrowMyToys();
            var v       = example.ValidateName(null);

            Assert.False(v.IsValid);
        }
Exemple #6
0
        public void GetOrElse_OnNoError_ReturnsValue()
        {
            var example = new ThrowMyToys();
            var v       = example.ValidateName("BooBoo");
            var result  = v.GetOrElse("Bob");

            Assert.Equal("BooBoo", result);
        }
Exemple #7
0
        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)
                );
        }
Exemple #8
0
        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);
        }