public virtual StopwatchV2 LogMethodEntered(string methodName, params object[] args) { #if DEBUG args = new StackFrame(2, true).AddTo(args); #endif Log.d(" --> " + methodName, args); if (!methodName.IsNullOrEmpty()) { EventBus.instance.Publish(EventConsts.catMethod + " ENTERED", methodName, args); } return(AssertV2.TrackTiming(methodName)); }
public virtual StopwatchV2 LogMethodEntered(string methodName, object[] args) { #if DEBUG args = new StackFrame(2, true).AddTo(args); #endif Log.d(" --> " + methodName, args); if (!methodName.IsNullOrEmpty()) { AppFlow.TrackEvent(EventConsts.catMethod, methodName, args); } return(AssertV2.TrackTiming(methodName)); }
public void TestAssertV2Methods() { AssertV2.ThrowExeptionIfAssertionFails(() => { AssertV2.IsTrue(1 + 1 == 2, "This assertion must not fail"); var s1 = "a"; AssertV2.AreEqual(s1, s1); AssertV2.IsNull(null, "myVarX"); AssertV2.AreEqual(1, 1); AssertV2.AreNotEqual(1, 2); }); var stopWatch = AssertV2.TrackTiming(); var res = 1f; for (float i = 1; i < 500000; i++) { res = i / res + i; } Assert.NotEqual(0, res); stopWatch.Stop(); AssertV2.ThrowExeptionIfAssertionFails(() => { stopWatch.AssertUnderXms(200); }); Assert.True(stopWatch.IsUnderXms(200), "More time was needed than expected!"); AssertV2.AreEqual("abcd", "abce"); AssertV2.AreEqual(new int[4] { 1, 2, 2, 4 }, new int[4] { 1, 2, 3, 4 }); AssertV2.AreEqual(new int[2] { 1, 2 }, new int[2] { 1, 3 }); AssertV2.AreEqual(new int[6] { 1, 2, 3, 4, 5, 6 }, new int[6] { 1, 2, 3, 4, 5, 7 }); AssertV2.AreEqual(new int[2] { 1, 2 }, new int[1] { 1 }); AssertV2.AreEqual(new int[1] { 1 }, new int[2] { 1, 2 }); }
public void TestAssertV2Methods() { AssertV2.ThrowExeptionIfAssertionFails(() => { AssertV2.IsTrue(AssertV2.throwExeptionIfAssertionFails, "AssertV2.throwExeptionIfAssertionFails"); AssertV2.IsTrue(1 + 1 == 2, "This assertion must not fail"); AssertV2.Throws <Exception>(() => { AssertV2.IsTrue(1 + 1 == 4, "This assertion has to fail"); Log.e("This line should never be printed since throwExeptionIfAssertionFails is true"); }); var s1 = "a"; AssertV2.AreEqual(s1, s1); AssertV2.IsTrue(AssertV2.throwExeptionIfAssertionFails, "AssertV2.throwExeptionIfAssertionFails"); AssertV2.Throws <Exception>(() => { AssertV2.AreNotEqual(s1, s1, "s1"); }); string myVarX = null; AssertV2.IsNull(null, "myVarX"); myVarX = "Now myVarX is not null anymore"; AssertV2.Throws <Exception>(() => { AssertV2.IsNull(myVarX, "myVarX"); }); AssertV2.AreEqual(1, 1); AssertV2.Throws <Exception>(() => { AssertV2.AreEqual(1, 2); }); AssertV2.AreNotEqual(1, 2); AssertV2.Throws <Exception>(() => { AssertV2.AreNotEqual(1, 1); }); var stopWatch = AssertV2.TrackTiming(); Thread.Sleep(10); stopWatch.Stop(); AssertV2.Throws <Exception>(() => { stopWatch.AssertUnderXms(1); }); // This should always fail stopWatch.AssertUnderXms(50); AssertV2.IsTrue(stopWatch.IsUnderXms(50), "More time was needed than expected!"); }); }