Exemplo n.º 1
0
        public void Equals_FailedInequalToSuccess()
        {
            var x = EValidation.Failure(new ArgumentException());
            var y = EValidation.Success;

            Assert.That(x.Equals(y), Is.False);
        }
Exemplo n.º 2
0
        public void Equals_FailureEqual()
        {
            var e = new ArgumentException();

            var x = EValidation.Failure(e);
            var y = EValidation.Failure(e);

            Assert.That(x.Equals(y), Is.True);
        }
Exemplo n.º 3
0
        public void ConvertToEOption_Failure()
        {
            var exception  = new ArgumentNullException();
            var validation = EValidation.Failure(exception);
            var option     = validation.ToEOption();

            Assert.That(option.IsFailure, Is.True);
            Assert.That(option.FailureOrThrow(), Is.EqualTo(exception));
        }
Exemplo n.º 4
0
        public void Equals_FailureInequal()
        {
            var e1 = new ArgumentException();
            var e2 = new ArgumentException();

            var x = EValidation.Failure(e1);
            var y = EValidation.Failure(e2);

            Assert.That(x.Equals(y), Is.False);
        }
Exemplo n.º 5
0
        public void Equals_Validation_DifferentType()
        {
            var aEValid = EValidation.Success;
            var aValid  = Validation <string> .Success;

            var exception = new ArgumentException();
            var bEValid   = EValidation.Failure(exception);
            var bValid    = Validation <string> .Failure("whatever");

            Assert.That(aEValid, Is.Not.EqualTo(aValid));
            Assert.That(bValid, Is.Not.EqualTo(bEValid));
            Assert.That(aValid, Is.Not.EqualTo(aEValid));
            Assert.That(bValid, Is.Not.EqualTo(bEValid));

            Assert.That(aEValid, Is.Not.EqualTo(bValid));  //sanity-check
        }
Exemplo n.º 6
0
        public void Equals_Validation()
        {
            var aEValid = EValidation.Success;
            var aValid  = Validation <Exception> .Success;

            var exception = new ArgumentException();
            var bEValid   = EValidation.Failure(exception);
            var bValid    = Validation <Exception> .Failure(exception);

            Assert.That(aEValid.GetHashCode(), Is.EqualTo(aValid.GetHashCode()), "HashCode not correct (Success-Case)");
            Assert.That(bEValid.GetHashCode(), Is.EqualTo(bValid.GetHashCode()), "HashCode not correct (Failure-Case)");

            Assert.That(aEValid, Is.EqualTo(aValid), "EValidation-Equals is buggy! (Success-Case)");
            Assert.That(bValid, Is.EqualTo(bEValid), "EValidation-Equals is buggy! (Failure-Case)");
            Assert.That(aValid, Is.EqualTo(aEValid), "Implementation of Validation is not accepting EValidation! (Success-Case)");
            Assert.That(bValid, Is.EqualTo(bEValid), "Implementation of Validation is not accepting EValidation! (Failure-Case)");

            Assert.That(aEValid, Is.Not.EqualTo(bValid));  //sanity-check
        }
Exemplo n.º 7
0
        public void ConstructFailure_ErrorNotNull()
        {
            var testValue = EValidation.Failure(new ArgumentException());

            Assert.That(testValue.IsSuccess, Is.False);
        }
Exemplo n.º 8
0
 public void ConstructFailure_ErrorNull()
 {
     Assert.That(() => EValidation.Failure(null), Throws.TypeOf <ValidationFailureConstructionException>());
 }
Exemplo n.º 9
0
        public void Error_ReturnsFailure()
        {
            var exception = new ArgumentNullException();

            Assert.That(EValidation.Failure(exception).FailureOrThrow(), Is.EqualTo(exception));
        }