PclUnit.Run.TestCycleExceptions.GetResult C# (CSharp) Méthode

GetResult() public méthode

public GetResult ( IAssertionHelper helper ) : ResultKind
helper IAssertionHelper
Résultat ResultKind
        public ResultKind GetResult(IAssertionHelper helper)
        {
            if (Test.OfType<IgnoreException>().Any())
                return ResultKind.Ignore;

            if(Setup.Any()
               || Teardown.Any()
               || Test.Any(it => !(it is ResultException)))
                return ResultKind.Error;

            if(Test.OfType<AssertionException>().Any())
                return ResultKind.Fail;

            if (!Assert._globalStyleUsed && helper.Assert.AssertCount == 0)
            {
                return ResultKind.NoError;
            }

            return ResultKind.Success;
        }

Usage Example

Exemple #1
0
        private void RunHelper(Object stateInfo)
        {
            var state = (State) stateInfo;
            var startTime = DateTime.Now;

            IAssertionHelper helper = new DummyHelper()
                                          {
                                              Assert = new Assert(),
                                              Log = new Log()
                                          };

            object fixture = null;
            var exceptions = new TestCycleExceptions();
            Result finalResult = null;
            try
            {

                fixture = _init(_type, _constructorArgs.Parameters);
                var helpertemp = fixture as IAssertionHelper;
                if (helpertemp != null)
                {
                    helpertemp.Assert = helper.Assert;
                    helpertemp.Log = helper.Log;
                    helper = helpertemp;
                }

                if (_constructorArgs.Disposed)
                {
                    throw new InvalidOperationException("Type ParameterSet Disposed Regenerated Tests to rerun");
                }
                if (_methodArgs.Disposed)
                {
                    throw new InvalidOperationException(
                        "Method ParameterSet Disposed Regenerated Tests to rerun");
                }

                try
                {
                    var result = _invoke(helper, _method, fixture, _methodArgs.Parameters);

                    //If the test method returns a boolean, true increments assertion
                    if (result as bool? ?? false)
                    {
                        helper.Assert.Okay();
                    }

                    //If the test method returns a boolean, false is fail
                    if (!(result as bool? ?? true))
                    {
                        helper.Assert.Fail("Test returned false.");
                    }

                    if (result is IReturnedResult)
                    {
                       finalResult = new Result(state.Platform,
                                                  startTime, DateTime.Now, result as IReturnedResult);
                    }
                }
                catch (Exception ex)
                {
                     exceptions.Add(TestCycle.Test, ex);
                }
            }
            catch (Exception ex)
            {
                exceptions.Add(TestCycle.Setup, ex);
            }
            finally
            {
                try
                {
                    var disposable = fixture as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    exceptions.Add(TestCycle.Teardown, ex);
                }
                exceptions.WriteOutExceptions(helper);
                state.Result = finalResult ?? new Result(state.Platform, exceptions.GetResult(helper), startTime, DateTime.Now, helper);
                state.Event.Set();
            }
        }
All Usage Examples Of PclUnit.Run.TestCycleExceptions::GetResult