public bool Equals(LogAndResult <T> other)
        {
            var err = false;

            if (this.ErrorCheck != null || other.ErrorCheck != null)
            {
                if (this.ErrorCheck != null && other.ErrorCheck != null)
                {
                    throw new InvalidOperationException();
                }

                var check = default(Func <Exception, bool>);
                var error = default(Exception);

                if (this.ErrorCheck != null)
                {
                    check = this.ErrorCheck;
                    error = other.Error;
                }
                else
                {
                    check = other.ErrorCheck;
                    error = this.Error;
                }

                err = check(error);
            }
            else
            {
                err = object.ReferenceEquals(Error, other.Error);
            }

            return(Log.SequenceEqual(other.Log) && EqualityComparer <T> .Default.Equals(Value, other.Value) && err);
        }
예제 #2
0
        private static void Verify <T>(LogAndResult <T> expected, Func <Func <string, Expression>, Expression> createExpression)
        {
            var res    = WithLog <T>(createExpression).CompileWithExceptionHandling();
            var actual = res();

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        private void AssertCompile(Func <Func <string, Expression>, Expression, Expression> createExpression, LogAndResult <object> expected)
        {
            var res = WithLog(createExpression).Compile()();

            Assert.AreEqual(expected, res);
        }
예제 #4
0
        private void AssertCompile <T>(Func <Func <Expression, string, Expression>, Expression> createExpression, LogAndResult <T> expected)
        {
            var res = WithLogValue <T>(createExpression).Compile()();

            Assert.AreEqual(expected, res);
        }
예제 #5
0
 public bool Equals(LogAndResult <T> other)
 {
     return(Log.SequenceEqual(other.Log) && EqualityComparer <T> .Default.Equals(Value, other.Value) && object.ReferenceEquals(Error, other.Error));
 }