コード例 #1
0
        private void WireUpEvents()
        {
            _model.Events.TestLoaded += (ea) =>
            {
                ClearCounters();

                _view.Initialize(ea.Test.TestCount);
                _view.DisplayText(ea.Test.TestCount > 0 ? "Ready" : "");
            };

            _model.Events.TestReloaded += (ea) =>
            {
                ClearCounters();

                _view.Initialize(ea.Test.TestCount);
                _view.DisplayText("Reloaded");
            };

            _model.Events.TestUnloaded += (ea) =>
            {
                ClearCounters();

                _view.Initialize(0);
                _view.DisplayText("Unloaded");
            };

            _model.Events.RunStarting += (ea) =>
            {
                ClearCounters();

                _view.Initialize(ea.TestCount);
                _view.DisplayTestsRun(0);
                _view.DisplayPassed(0);
                _view.DisplayFailed(0);
                _view.DisplayWarnings(0);
                _view.DisplayInconclusive(0);
                _view.DisplayTime(0.0);
            };

            _model.Events.RunFinished += (ea) =>
            {
                _view.DisplayText("Completed");
                _view.DisplayTime(ea.Result.Duration);
            };

            _model.Events.TestStarting += (ea) =>
            {
                _view.DisplayText(ea.Test.FullName);
            };

            _model.Events.TestFinished += (ea) =>
            {
                _view.DisplayTestsRun(++_testsRun);

                switch (ea.Result.Outcome.Status)
                {
                case TestStatus.Passed:
                    _view.DisplayPassed(++_passedCount);
                    break;

                case TestStatus.Failed:
                    _view.DisplayFailed(++_failedCount);
                    break;

                case TestStatus.Warning:
                    _view.DisplayWarnings(++_warningCount);
                    break;

                case TestStatus.Inconclusive:
                    _view.DisplayInconclusive(++_inconclusiveCount);
                    break;
                }
            };
        }