/// <summary> /// Executes the Act part of the test and its related Smart Assertions. /// </summary> /// <param name="cases">The <see cref="SmartTests.Case" /> expression for the tested code.</param> /// <param name="act">An <see cref="Act" /> instance representing the tested code.</param> /// <param name="assertions">The Smart Assertions for this <paramref name="act" />.</param> /// <remarks> /// If you need to specify <see cref="Criteria" /> expressions for multiple parameters, you have to use /// <see cref="RunTest(SmartTests.Case,Act,SmartTests.Assertion[])" /> instead. /// </remarks> /// <example> /// <code> /// [Test] /// public void ReturnVoidTest() /// { /// var mc = new MyClass( 10 ); /// /// RunTest( Case( "p1", MinIncluded.IsAboveMin ) & /// Case( "p2", MinIncluded.IsAboveMin ), /// () => mc.SetValues( 2, 3 ) ); /// /// Assert.AreEqual( 2, mc.Value1 ); /// Assert.AreEqual( 3, mc.Value2 ); /// } /// </code> /// </example> /// <seealso cref="RunTest(Criteria,Expression{Action},SmartTests.Assertion[])" /> /// <seealso cref="RunTest(SmartTests.Case,Expression{Action},SmartTests.Assertion[])" /> /// <seealso cref="Case(Criteria)" /> /// <seealso cref="Case(string,Criteria)" /> /// <seealso cref="Criteria" /> /// <seealso cref="Assertion" /> /// <exception cref="SmartTestException">In case a Smart <see cref="Assertion" /> fails after the <paramref name="act" />.</exception> /// <exception cref="BadTestException">In case a Smart <see cref="Assertion" /> fails before the <paramref name="act" />.</exception> public static void RunTest(Case cases, Act act, params Assertion[] assertions) { if (act == null) { throw new ArgumentNullException(nameof(act)); } act.Assertions = assertions; try { act.BeforeAct(); act.Invoke(act.Context); } catch (Exception e) { e = e.NoInvocation(); act.Exception = e; act.AfterAct(); if (e is SmartTestException) { // ReSharper disable once PossibleIntendedRethrow throw e; } throw new SmartTestException("Unexpected error occurred!", e); } act.AfterAct(); }