public void TryGetInfo_inside_test_method() { var res = new CallStackReflector().TryGetLocation(); Assert.IsTrue(res.Filepath.EndsWith("ReflectorTest.cs")); Assert.AreEqual(37, res.LineNumber); }
public void TryGetInfo_inside_AssertThrowsLambda_expected_outside_lambda() { UnitTestLocationInfo res = null; Assert.DoesNotThrow(() => res = new CallStackReflector().TryGetLocation()); Assert.IsTrue(res.Filepath.EndsWith("ReflectorTest.cs")); Assert.AreEqual(60, res.LineNumber); }
/// <summary> /// Assert that two strings are the same using the configures asserter method. Upon a failure, a suggested string for correcting the test /// is printed. /// </summary> public void AreEqual(string expected, string actual) { if (expected == actual) { return; } var reflector = new CallStackReflector(); var info = reflector.TryGetLocation(); CallUnderlyingAssert(expected, actual, info); }
/// <summary> /// Assert that two strings are the same using the configures asserter method. Upon a failure, a suggested string for correcting the test /// is printed. /// </summary> public void AreEqual(string expected, string actual) { if (expected == actual) { return; } var escapedActual = Escape(actual); var newExpected = string.Format("var expected = {0};", escapedActual); var message = string.Format("{0}{0}Proposed output for unit test:{0}{0}{1}{0}", Environment.NewLine, newExpected); var reflector = new CallStackReflector(); var info = reflector.TryGetLocation(); CallUnderlyingAssert(expected, actual, info, message, escapedActual); }
/// <summary> /// Assert that two strings are the same using the configures asserter method. Upon a failure, a suggested string for correcting the test /// is printed. /// </summary> public void AreEqual(string expected, string actual) { if (expected == actual) return; var reflector = new CallStackReflector(); var info = reflector.TryGetLocation(); CallUnderlyingAssert(expected, actual, info); }