public IEnumerable <string> GetErrorMessages() { IList <string> errors = new List <string>(); try { int hash1 = (int)this.Method.Invoke(this.TargetInstance, new object[0]); int hash2 = (int)this.Method.Invoke(this.OtherObject, new object[0]); if (hash1 != hash2) { errors.Add($"{MethodExtensions.GetSignature(this.Method)} returned distinct values on equal objects."); } } catch (TargetInvocationException invocationExc) { errors.Add($"{MethodExtensions.GetSignature(this.Method)} failed - {invocationExc.Message}."); } catch (Exception exc) { errors.Add($"{MethodExtensions.GetSignature(this.Method)} failed - {exc.Message}."); } return(errors); }
public IEnumerable <string> GetErrorMessages() { IList <string> errors = new List <string>(); try { TResult actualResult = (TResult)this.Method.Invoke(this.TargetObject, this.MethodParameters); if (!actualResult.Equals(this.ExpectedResult)) { errors.Add( $"{MethodExtensions.GetSignature(this.Method, this.MethodLabel)} returned {actualResult} when expecting {this.ExpectedResult} - {this.TestCase}"); } } catch (TargetInvocationException invocationExc) { errors.Add($"{MethodExtensions.GetSignature(this.Method)} failed - {invocationExc.Message}."); } catch (Exception exc) { errors.Add($"{MethodExtensions.GetSignature(this.Method)} failed - {exc.Message}."); } return(errors); }