예제 #1
0
        public static object GetAnonymousListener(SessionResults sessionResults, List <TestResult> testResults, ResultFormatterFactory resultFormatterFactory)
        {
            return(new
            {
                OnAssemblyStart = ReturnVoid.Arguments <dynamic>(assembly => { }),

                OnAssemblyEnd = ReturnVoid.Arguments <dynamic>(assembly => { }),

                OnRunStart = ReturnVoid.Arguments(() => { }),

                OnRunEnd = ReturnVoid.Arguments(() => testResults.ForEach(x => sessionResults.TestResults.Add(x))),

                OnContextStart = ReturnVoid.Arguments <dynamic>(context =>
                {
                    string r = string.Format("\n{0}", context.FullName);
                    sessionResults.Messages.Add(r);
                }),

                OnContextEnd = ReturnVoid.Arguments <dynamic>(context => { }),

                OnSpecificationStart = ReturnVoid.Arguments <Object>(specification => { }),

                OnSpecificationEnd = ReturnVoid.Arguments <dynamic, dynamic>((specification, result) =>
                {
                    var formatter = ResultFormatterFactory.GetResultFormatterFor(result: result.Status.ToString());

                    string formatResult = formatter.FormatResult(specification, result);
                    sessionResults.Messages.Add(formatResult);

                    var testResult =
                        new TestResult {
                        Name = specification.Name, TestRunner = "MSPEC"
                    };

                    ProcessTestResult((object)result, testResult, testResults);
                }),

                OnFatalError = ReturnVoid.Arguments <dynamic>(exception => sessionResults.Messages.Add("Fatal error: " + exception)),

                sessionResults,

                testResults,

                resultFormatterFactory
            });
        }
예제 #2
0
        public static object GetAnonymousListener(SessionResults sessionResults, List<TestResult> testResults, ResultFormatterFactory resultFormatterFactory)
        {
            return new
                {
                    OnAssemblyStart = ReturnVoid.Arguments<dynamic>(assembly => { }),

                    OnAssemblyEnd = ReturnVoid.Arguments<dynamic>(assembly => { }),

                    OnRunStart = ReturnVoid.Arguments(() => { }),

                    OnRunEnd = ReturnVoid.Arguments(() => testResults.ForEach(x => sessionResults.TestResults.Add(x))),

                    OnContextStart = ReturnVoid.Arguments<dynamic>(context =>
                                                                       {
                                                                           string r = string.Format("\n{0}", context.FullName);
                                                                           sessionResults.Messages.Add(r);
                                                                       }),

                    OnContextEnd = ReturnVoid.Arguments<dynamic>(context => { }),

                    OnSpecificationStart = ReturnVoid.Arguments<Object>(specification => { }),

                    OnSpecificationEnd = ReturnVoid.Arguments<dynamic, dynamic>((specification, result) =>
                                        {
                                            var formatter = ResultFormatterFactory.GetResultFormatterFor(result: result.Status.ToString());

                                            string formatResult = formatter.FormatResult(specification, result);
                                            sessionResults.Messages.Add(formatResult);

                                            var testResult =
                                                new TestResult { Name = specification.Name, TestRunner = "MSPEC" };

                                            ProcessTestResult((object) result, testResult, testResults);
                                        }),

                    OnFatalError = ReturnVoid.Arguments<dynamic>(exception => sessionResults.Messages.Add("Fatal error: " + exception)),

                    sessionResults,

                    testResults,

                    resultFormatterFactory
                };
        }