Пример #1
0
        public ClassEnvironment(string alternativeSourceFilePath = null, [CallerFilePath] string sourceFilePath = "")
        {
            ThisClassesLog = new ClassLog(alternativeSourceFilePath ?? sourceFilePath);
            MasterEnvironment.AddClassLog( ThisClassesLog);

            //ensure the database is set up
            using (var db = new EfTestDbContext())
            {
                if (!db.EfParents.Any()) db.ResetDatabaseContent();     //make sure database is loaded after change to model
            }
        }
        public ClassLogClassified(ClassLog classLog)
        {
            var numTests = classLog.ValidMethodLogs.Count();
            if (numTests == 0) return;

            var numSupportedResults = classLog.ValidMethodLogs.Count(x => x.State == LogStates.Supported);
            Classification = numTests == numSupportedResults 
                ? ClassClassifications.Supported 
                : numSupportedResults == 0
                    ? ClassClassifications.NotSupported
                    : ClassClassifications.PartiallySupported;

            DisplayMarkupNoPrefix = Classification == ClassClassifications.PartiallySupported
                ? string.Format("{0} ({1} of {2} tests passed)", classLog.TestNameAsMarkupLinkRelativeToDocumentationDir, numSupportedResults, numTests)
                : string.Format("{0} ({1} tests)", classLog.TestNameAsMarkupLinkRelativeToDocumentationDir, numTests);
        }
        public void TestDetailOneGroupSupported()
        {
            //SETUP
            MasterEnvironment.ResetLogging();
            var classLog = new ClassLog(@"TestGroup01UnitTestGroup\Test01MyUnitTest");
            MasterEnvironment.AddClassLog(classLog);
            example2Supported.ForEach(classLog.MethodLogs.Add);

            //ATTEMPT
            var markup = MasterEnvironment.ResultsAsMarkup(OutputVersions.Detail);

            //VERIFY
            markup.ShouldStartWith("Detail");
            markup.ShouldContain("Group: Unit Test Group");
            markup.ShouldContain("\n#### [My Unit Test](");
            markup.ShouldContain("\n- Supported\n  * Good1 (line 1)\n  * Good2 (line 2)");
        }
        public void TestDetailWithSqlOneGroupPartiallySupported()
        {
            //SETUP
            MasterEnvironment.ResetLogging();
            var classLog = new ClassLog(@"TestGroup01UnitTestGroup\Test01MyUnitTest");
            MasterEnvironment.AddClassLog(classLog);
            example1PartiallySupported.ForEach(classLog.MethodLogs.Add);

            //ATTEMPT
            var markup = MasterEnvironment.ResultsAsMarkup(OutputVersions.DetailWithSql);

            //VERIFY
            markup.ShouldStartWith("Detail With Sql");
            markup.ShouldContain("Group: Unit Test Group");
            markup.ShouldContain("\n#### [My Unit Test](");
            markup.ShouldContain("\n- Supported\n  * Good (line 1)\n     * T-Sql executed is\n\n```SQL");
            markup.ShouldContain("\n- **Not Supported**\n  * Bad (line 2)");
        }
        public void TestSummaryOneGroupNotSupported()
        {
            //SETUP
            MasterEnvironment.ResetLogging();
            var classLog = new ClassLog(@"TestGroup01UnitTestGroup\Test01MyUnitTest");
            MasterEnvironment.AddClassLog(classLog);
            example3NotSupported.ForEach(classLog.MethodLogs.Add);

            //ATTEMPT
            var markup = MasterEnvironment.ResultsAsMarkup(OutputVersions.Summary);

            //VERIFY
            markup.ShouldStartWith("Summary");
            markup.ShouldContain("Group: Unit Test Group");
            markup.ShouldContain("\n- **Not Supported**\n");
            markup.ShouldContain(
                "\n  * [My Unit Test](../TestGroup01UnitTestGroup/Test01MyUnitTest) (2 tests)");
        }
 public static void AddClassLog(ClassLog classLog)
 {
     classLog.Order = OrderInc++;
     _classLogs.Add(classLog);
 }
        public void TestSummaryOneGroupTwoClassesSupported()
        {
            //SETUP
            MasterEnvironment.ResetLogging();
            var classLog1 = new ClassLog(@"TestGroup01UnitTestGroup\Test01MyUnitTest1");
            MasterEnvironment.AddClassLog(classLog1);
            example2Supported.ForEach(classLog1.MethodLogs.Add);
            var classLog2 = new ClassLog(@"TestGroup01UnitTestGroup\Test01MyUnitTest2");
            MasterEnvironment.AddClassLog(classLog2);
            example2Supported.ForEach(classLog2.MethodLogs.Add);

            //ATTEMPT
            var markup = MasterEnvironment.ResultsAsMarkup(OutputVersions.Summary);

            //VERIFY
            markup.ShouldStartWith("Summary");
            markup.ShouldContain("Group: Unit Test Group");
            markup.ShouldContain("\n- Supported\n");
            markup.ShouldContain("\n  * [My Unit Test1]");
            markup.ShouldContain("\n  * [My Unit Test2](");
        }