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); }
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); }
private void AssertCompile(Func <Func <string, Expression>, Expression, Expression> createExpression, LogAndResult <object> expected) { var res = WithLog(createExpression).Compile()(); Assert.AreEqual(expected, res); }
private void AssertCompile <T>(Func <Func <Expression, string, Expression>, Expression> createExpression, LogAndResult <T> expected) { var res = WithLogValue <T>(createExpression).Compile()(); Assert.AreEqual(expected, res); }
public bool Equals(LogAndResult <T> other) { return(Log.SequenceEqual(other.Log) && EqualityComparer <T> .Default.Equals(Value, other.Value) && object.ReferenceEquals(Error, other.Error)); }