private List <TestResult> CollectTestResults(IEnumerable <TestCase> testCasesRun, string resultXmlFile, List <string> consoleOutput, string baseDir)
        {
            var testResults = new List <TestResult>();

            TestCase[] testCasesRunAsArray = testCasesRun as TestCase[] ?? testCasesRun.ToArray();
            var        xmlParser           = new XmlTestResultParser(testCasesRunAsArray, resultXmlFile, _testEnvironment, baseDir);
            var        consoleParser       = new StandardOutputTestResultParser(testCasesRunAsArray, consoleOutput, _testEnvironment, baseDir);

            testResults.AddRange(xmlParser.GetTestResults());
            _testEnvironment.DebugInfo($"Collected {testResults.Count} test results from XML result file '{resultXmlFile}'");

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                List <TestResult> consoleResults = consoleParser.GetTestResults();
                int nrOfCollectedTestResults     = 0;
                // ReSharper disable once AccessToModifiedClosure
                foreach (TestResult testResult in consoleResults.Where(tr => !testResults.Exists(tr2 => tr.TestCase.FullyQualifiedName == tr2.TestCase.FullyQualifiedName)))
                {
                    testResults.Add(testResult);
                    nrOfCollectedTestResults++;
                }
                _testEnvironment.DebugInfo($"Collected {nrOfCollectedTestResults} test results from console output");
            }

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                string errorMessage, errorStackTrace = null;
                if (consoleParser.CrashedTestCase == null)
                {
                    errorMessage = "";
                }
                else
                {
                    errorMessage    = $"reason is probably a crash of test {consoleParser.CrashedTestCase.DisplayName}";
                    errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                               consoleParser.CrashedTestCase.CodeFilePath, consoleParser.CrashedTestCase.LineNumber.ToString());
                }
                int nrOfCreatedTestResults = 0;
                // ReSharper disable once AccessToModifiedClosure
                foreach (TestCase testCase in testCasesRunAsArray.Where(tc => !testResults.Exists(tr => tr.TestCase.FullyQualifiedName == tc.FullyQualifiedName)))
                {
                    testResults.Add(new TestResult(testCase)
                    {
                        ComputerName    = Environment.MachineName,
                        Outcome         = TestOutcome.Skipped,
                        ErrorMessage    = errorMessage,
                        ErrorStackTrace = errorStackTrace
                    });
                    nrOfCreatedTestResults++;
                }
                _testEnvironment.DebugInfo($"Created {nrOfCreatedTestResults} test results for tests which were neither found in result XML file nor in console output");
            }

            testResults = testResults.OrderBy(tr => tr.TestCase.FullyQualifiedName).ToList();

            return(testResults);
        }
 public void ExtractQuotedTest()
 {
     Assert.AreEqual("hello", ErrorMessageParser.ExtractQuotedText("hello"));
     Assert.AreEqual("hello", ErrorMessageParser.ExtractQuotedText("\"hello\""));
     Assert.AreEqual("hello", ErrorMessageParser.ExtractQuotedText("!!\"hello\""));
     Assert.AreEqual("hello", ErrorMessageParser.ExtractQuotedText("\"hello\"!!"));
     Assert.AreEqual("hello", ErrorMessageParser.ExtractQuotedText("!!\"hello\"!!"));
     Assert.AreEqual(string.Empty, ErrorMessageParser.ExtractQuotedText("\"\"!!"));
 }
 private void RunAllTests(ErrorMessageParser parser)
 {
     RunTest(parser, 1, "whatever", "whatever");
     RunTest(parser, 2, "AAA??BBB", "??");
     RunTest(parser, 3, "'aaa'HELLO", "'aaa'");
     RunTest(parser, 4, "BYE123", "123");
     RunTest(parser, 5, "A1B2C3", "1", "2", "3");
     RunTest(parser, 6, "~", "~");
 }
        public void TestIfErrorsAreParsedCorrectly()
        {
            var errorMessagesMap = ErrorMessageParser.Parse("UnitTests");

            Assert.That(errorMessagesMap, Is.Not.Null);
            Assert.That(errorMessagesMap.Count, Is.EqualTo(3));
            Assert.That(errorMessagesMap["UnitTests.TestErrorDiscription.Method1"], Is.EqualTo("Click Make Payment"));
            Assert.That(errorMessagesMap["UnitTests.TestErrorDiscription.Method2"], Is.EqualTo("Fill CreditCardInfo"));
            Assert.That(errorMessagesMap["UnitTests.TestErrorDiscription.Method3"], Is.EqualTo("On Payment Page"));
        }
        private void RunTest(ErrorMessageParser parser, int code, string input, params string[] expected)
        {
            var actual = parser.Parse(code, input);

            Assert.AreEqual(expected.Length, actual.Count);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i + 1]);
            }
        }
        public Log4Error()
        {
            var dllList = Log4ErrorConfigSectionReader.GetDllList();

            foreach (var dll in dllList)
            {
                var tempDictionary = ErrorMessageParser.Parse(dll);
                ErrorMap = ErrorMap.Concat(tempDictionary).ToDictionary(x => x.Key, x => x.Value);
            }
        }
        private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase, List <TestResult> testResults)
        {
            var errorMessage    = $"reason is probably a crash of test {crashedTestCase.DisplayName}";
            var errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                           crashedTestCase.CodeFilePath, crashedTestCase.LineNumber.ToString());

            testResults.AddRange(testCases.Select(testCase =>
                                                  CreateTestResult(testCase, TestOutcome.Skipped, errorMessage, errorStackTrace)));
            if (testCases.Length > 0)
            {
                _logger.DebugInfo($"{_threadName}Created {testCases.Length} test results for tests which were neither found in result XML file nor in console output");
            }
        }
        public async Task <ActionResult> GenerateDocumentationMatrixConfirmed(int customerID)
        {
            try
            {
                await customerRepository.GenerateDocumentationMatrix(customerID, true);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ErrorMessageParser.Parse(ex.Message));
                return(View());
            }
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try
            {
                await customerRepository.DeleteAsync(id);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ErrorMessageParser.Parse(ex.Message));
                //ModelState.AddModelError("", ex.Message);
                return(View());
            }
        }
예제 #10
0
        private List <TestResult> CollectTestResults(IEnumerable <TestCase> testCasesRun, string resultXmlFile, List <string> consoleOutput, string baseDir)
        {
            List <TestResult> testResults = new List <TestResult>();

            TestCase[]                     testCasesRunAsArray = testCasesRun as TestCase[] ?? testCasesRun.ToArray();
            XmlTestResultParser            xmlParser           = new XmlTestResultParser(testCasesRunAsArray, resultXmlFile, TestEnvironment, baseDir);
            StandardOutputTestResultParser consoleParser       = new StandardOutputTestResultParser(testCasesRunAsArray, consoleOutput, TestEnvironment, baseDir);

            testResults.AddRange(xmlParser.GetTestResults());

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                List <TestResult> consoleResults = consoleParser.GetTestResults();
                foreach (TestResult testResult in consoleResults.Where(tr => !testResults.Exists(tr2 => tr.TestCase.FullyQualifiedName == tr2.TestCase.FullyQualifiedName)))
                {
                    testResults.Add(testResult);
                }
            }

            if (testResults.Count < testCasesRunAsArray.Length)
            {
                string errorMessage, errorStackTrace = null;
                if (consoleParser.CrashedTestCase == null)
                {
                    errorMessage = "";
                }
                else
                {
                    errorMessage    = "reason is probably a crash of test " + consoleParser.CrashedTestCase.DisplayName;
                    errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                               consoleParser.CrashedTestCase.CodeFilePath, consoleParser.CrashedTestCase.LineNumber.ToString());
                }
                foreach (TestCase testCase in testCasesRunAsArray.Where(tc => !testResults.Exists(tr => tr.TestCase.FullyQualifiedName == tc.FullyQualifiedName)))
                {
                    testResults.Add(new TestResult(testCase)
                    {
                        ComputerName    = Environment.MachineName,
                        Outcome         = TestOutcome.Skipped,
                        ErrorMessage    = errorMessage,
                        ErrorStackTrace = errorStackTrace
                    });
                }
            }

            return(testResults);
        }
        public void RealMessagesTest()
        {
            var parser = CreateParser(true,
                                      "Cannot insert the value NULL into column '%.*ls', table '%.*ls'; column does not allow nulls. %ls fails.",
                                      "The %ls statement conflicted with the %ls constraint \"%.*ls\". The conflict occurred in database \"%.*ls\", table \"%.*ls\"%ls%.*ls%ls.",
                                      "Cannot insert duplicate key row in object '%.*ls' with unique index '%.*ls'. The duplicate key value is %ls.",
                                      "Violation of %ls constraint '%.*ls'. Cannot insert duplicate key in object '%.*ls'. The duplicate key value is %ls.");

            const string canNotInsertNull = "Cannot insert the value NULL into column 'col', table 'DO40-Tests.dbo.Table_1'; column does not allow nulls. INSERT fails.";
            var          result           = parser.Parse(1, canNotInsertNull);

            Assert.AreEqual(3, result.Count);
            Assert.AreEqual("col", result[1]);
            Assert.AreEqual("Table_1", ErrorMessageParser.CutDatabaseAndSchemaPrefix(result[2]));
            Assert.AreEqual("INSERT", result[3]);

            const string violationOfForeignKey = "The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Table_2_Table_1\". The conflict occurred in database \"DO40-Tests\", table \"dbo.Table_1\", column 'col'.";

            result = parser.Parse(2, violationOfForeignKey);
            Assert.AreEqual(6, result.Count);
            Assert.AreEqual("INSERT", result[1]);
            Assert.AreEqual("FOREIGN KEY", result[2]);
            Assert.AreEqual("FK_Table_2_Table_1", result[3]);
            Assert.AreEqual("DO40-Tests", result[4]);
            Assert.AreEqual("Table_1", ErrorMessageParser.CutSchemaPrefix(result[5]));
            Assert.AreEqual("col", ErrorMessageParser.ExtractQuotedText(result[6]));

            const string canNotInsertDuplicateKey = "Cannot insert duplicate key row in object 'dbo.Table_1' with unique index 'Test'. The duplicate key value is (1).";

            result = parser.Parse(3, canNotInsertDuplicateKey);
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual("Table_1", ErrorMessageParser.CutSchemaPrefix(result[1]));
            Assert.AreEqual("Test", result[2]);
            Assert.AreEqual("(1)", result[3]);

            const string violationOfPrimaryKey = "Violation of PRIMARY KEY constraint 'PK_Table_1'. Cannot insert duplicate key in object 'dbo.Table_1'. The duplicate key value is (1).";

            result = parser.Parse(4, violationOfPrimaryKey);
            Assert.AreEqual(4, result.Count);
            Assert.AreEqual("PRIMARY KEY", result[1]);
            Assert.AreEqual("PK_Table_1", result[2]);
            Assert.AreEqual("Table_1", ErrorMessageParser.CutSchemaPrefix(result[3]));
            Assert.AreEqual("(1)", result[4]);
        }
예제 #12
0
        private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase, List <TestResult> testResults)
        {
            var errorMessage    = $"reason is probably a crash of test {crashedTestCase.DisplayName}";
            var errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                           crashedTestCase.CodeFilePath, crashedTestCase.LineNumber.ToString());

            foreach (TestCase testCase in testCases)
            {
                testResults.Add(new TestResult(testCase)
                {
                    ComputerName    = Environment.MachineName,
                    Outcome         = TestOutcome.Skipped,
                    ErrorMessage    = errorMessage,
                    ErrorStackTrace = errorStackTrace
                });
            }
            if (testCases.Length > 0)
            {
                _logger.DebugInfo($"{_threadName}Created {testCases.Length} test results for tests which were neither found in result XML file nor in console output");
            }
        }
예제 #13
0
        private void CreateMissingResults(TestCase[] testCases, TestCase crashedTestCase, List <TestResult> testResults)
        {
            var errorMessage    = String.Format(Resources.CrashTest, crashedTestCase.DisplayName);
            var errorStackTrace = ErrorMessageParser.CreateStackTraceEntry("crash suspect",
                                                                           crashedTestCase.CodeFilePath, crashedTestCase.LineNumber.ToString());

            foreach (TestCase testCase in testCases)
            {
                testResults.Add(new TestResult(testCase)
                {
                    ComputerName    = Environment.MachineName,
                    Outcome         = TestOutcome.Skipped,
                    ErrorMessage    = errorMessage,
                    ErrorStackTrace = errorStackTrace
                });
            }
            if (testCases.Length > 0)
            {
                _logger.DebugInfo(String.Format(Resources.CreatedTestResults, _threadName, testCases.Length));
            }
        }
예제 #14
0
        // As far as SqlGeometry and SqlGeography have no support in .Net Standard
        // these two methods are useless

        //protected override void RegisterCustomMappings(TypeMappingRegistryBuilder builder)
        //{
        //  base.RegisterCustomMappings(builder);
        //  builder.Add(new GeometryMapper());
        //  builder.Add(new GeographyMapper());
        //}

        //protected override void RegisterCustomReverseMappings(TypeMappingRegistryBuilder builder)
        //{
        //  base.RegisterCustomReverseMappings(builder);

        //  builder.AddReverse(CustomSqlType.Geometry, Type.GetType("Microsoft.SqlServer.Types.SqlGeometry, Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"));
        //  builder.AddReverse(CustomSqlType.Geography, Type.GetType("Microsoft.SqlServer.Types.SqlGeography, Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"));
        //}

        // Constructors

        public Driver(CoreServerInfo coreServerInfo, ErrorMessageParser errorMessageParser, bool checkConnectionIsAlive)
            : base(coreServerInfo, errorMessageParser, checkConnectionIsAlive)
        {
        }