Пример #1
0
 public void TestLogTextWithNewlines()
 {
     StfLogger.LogLevel = StfLogLevel.Info;
     StfLogger.LogInfo("Single line 1");
     StfLogger.LogInfo(string.Format("Entering Multi line{0}Second row{0}Third row{0}{0}Blank line above{0}Last line", Environment.NewLine));
     StfLogger.LogInfo("Single line 2");
 }
Пример #2
0
        public void DatadrivenLoggerTest3LinesLine1Fail()
        {
            var iteration = (int)TestContext.DataRow["Iteration"];
            var message   = (string)TestContext.DataRow["Message"];
            var failPass  = ConvertToBool((string)TestContext.DataRow["FailPass"]);

            StfLogger.LogInfo($"Iteration [{iteration}]: {message}");
            Assert.IsTrue(StfAssert.IsTrue("FailPass", failPass) == failPass);
        }
Пример #3
0
        public void TestMethodLotsOfEntries()
        {
            StfLogger.LogLevel = StfLogLevel.Internal;

            for (int i = 0; i < 75; i++)
            {
                StfLogger.LogInfo($"LogInfo Nr {i}");
            }

            StfLogger.CloseLogFile();
        }
Пример #4
0
        /// <summary>
        /// The helper datadriven with testdata object.
        /// </summary>
        /// <returns>
        /// The <see cref="UnitTestTestDataObject"/>.
        /// </returns>
        private UnitTestTestDataObject HelperDatadrivenWithTestdataObject()
        {
            var testdata = new UnitTestTestDataObject {
                Iteration = "-1"
            };

            testdata = InitTestData(testdata);

            StfLogger.LogInfo($"Iteration [{testdata.Iteration}]: {testdata.Message}");
            StfAssert.AreEqual("Iteration", testdata.Iteration, testdata.StfIteration.ToString());

            return(testdata);
        }
Пример #5
0
        public void TestLogTextWithInvalidXmlContent()
        {
            var xmlToLog = string.Format(@"<xmltags>{0}<xmltag>{0}Line 1{0}      Six Space indent{0}</xmltag>{0}</WRONG_CLOSING_TAG>{0}", Environment.NewLine);

            StfLogger.LogLevel = StfLogLevel.Info;

            StfLogger.LogSubHeader("xml without anything");
            StfLogger.LogInfo(xmlToLog);

            StfLogger.LogSubHeader("Using Escape");
            StfLogger.LogInfo(System.Security.SecurityElement.Escape(xmlToLog));

            StfLogger.LogSubHeader("Using logXml");
            StfLogger.LogXmlMessage(xmlToLog);
        }
Пример #6
0
        public void DatadrivenLoggerTest()
        {
            var iteration = (int)TestContext.DataRow["Iteration"];
            var message   = (string)TestContext.DataRow["Message"];

            StfLogger.LogInfo($"Iteration [{iteration}]: {message}");

            // need to close the logfile, in order to check the content of the logfile...
            StfLogger.CloseLogFile();

            // we want to fail, if FileContains fails
            StfAssert.EnableNegativeTesting = false;

            StfAssert.FileContains(iteration.ToString(), StfLogger.FileName, message);
        }
Пример #7
0
        public void TestMethodAllLogTypeWithFormatting()
        {
            StfLogger.LogLevel = StfLogLevel.Internal;

            StfLogger.LogError("{0}", "LogError");
            StfLogger.LogWarning("{0}", "LogWarning");
            StfLogger.LogInfo("{0}", "LogInfo");
            StfLogger.LogDebug("{0}", "LogDebug");
            StfLogger.LogTrace("{0}", "LogTrace");
            StfLogger.LogInternal("{0}", "LogInternal");
            StfLogger.LogHeader("{0}", "LogHeader");
            StfLogger.LogSubHeader("{0}", "LogSubHeader");

            StfLogger.LogError("{0} - {1}", "LogError", new List <string>());
            StfLogger.LogWarning("{0} - {1}", "LogWarning", new { Test = "Test" });
            StfLogger.LogInfo("{0} - {1} - {2}", "LogInfo", 42, 84);

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunction", new object[] { "arg1", "arg2", "arg3" });
            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunction", 42);

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunctionShort");
            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunctionShort");

            // used solely by Assert functions
            StfLogger.LogPass("testStepName LogPass", "{0}", "LogPass");
            StfLogger.LogFail("testStepName LogFail", "{0}", "LogFail");
            StfLogger.LogInconclusive("testStepName LogInconclusive", "Inconclusive result: {0}", 1);

            StfLogger.LogKeyValue("SomeKey", "SomeValue", "{0}", "LogKeyValue");

            StfLogger.LogGetEnter(StfLogLevel.Info, "MyTestProperty");
            StfLogger.LogGetExit(StfLogLevel.Info, "MyTestProperty", StfLogger);
            StfLogger.LogSetEnter(StfLogLevel.Info, "MyTestProperty", StfLogger);
            StfLogger.LogSetExit(StfLogLevel.Info, "MyTestProperty", StfLogger);

            StfLogger.LogAutomationIdObject(StfLogLevel.Internal, StfLogger, "Using StfLogger as AID for test");

            StfLogger.SetRunStatus();
        }
Пример #8
0
        public void TestMethodCallStack()
        {
            StfLogger.LogLevel = StfLogLevel.Internal;

            StfLogger.LogInfo("NameOfFunction_L0A");
            StfLogger.LogInfo("NameOfFunction_L0B");

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunction_L1");
            StfLogger.LogInfo("NameOfFunction_L1A");
            StfLogger.LogInfo("NameOfFunction_L1B");

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunction_L2");
            StfLogger.LogInfo("NameOfFunction_L2A");
            StfLogger.LogInfo("NameOfFunction_L2B");

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunction_L3");
            StfLogger.LogInfo("NameOfFunction_L3A");
            StfLogger.LogInfo("NameOfFunction_L3B");

            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunction_L3");
            StfLogger.LogInfo("NameOfFunction_L2A");
            StfLogger.LogInfo("NameOfFunction_L2B");

            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunction_L2");
            StfLogger.LogInfo("NameOfFunction_L1A");
            StfLogger.LogInfo("NameOfFunction_L1B");

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunction_L2");
            StfLogger.LogInfo("NameOfFunction_L2A");
            StfLogger.LogInfo("NameOfFunction_L2B");

            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunction_L2");
            StfLogger.LogInfo("NameOfFunction_L1A");
            StfLogger.LogInfo("NameOfFunction_L1B");

            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunction_L1");
            StfLogger.LogInfo("NameOfFunction_L0A");
            StfLogger.LogInfo("NameOfFunction_L0B");
        }
Пример #9
0
        public void TestMethodAllLogType()
        {
            StfLogger.LogLevel = StfLogLevel.Internal;

            StfLogger.LogError("LogError");
            StfLogger.LogWarning("LogWarning");
            StfLogger.LogInfo("LogInfo");
            StfLogger.LogDebug("LogDebug");

            // normal logging functions - models and adapters
            StfLogger.LogTrace("LogTrace");
            StfLogger.LogInternal("LogInternal");

            // Header logging functions - testscripts
            StfLogger.LogHeader("LogHeader");
            StfLogger.LogSubHeader("LogSubHeader");

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunction", new object[] { "arg1", "arg2", "arg3" });
            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunction", 42);

            StfLogger.LogFunctionEnter(StfLogLevel.Info, "Int", "NameOfFunctionShort");
            StfLogger.LogFunctionExit(StfLogLevel.Info, "NameOfFunctionShort");

            // used solely by Assert functions
            StfLogger.LogPass("testStepName LogPass", "LogPass");
            StfLogger.LogFail("testStepName LogFail", "LogFail");

            StfLogger.LogKeyValue("SomeKey", "SomeValue", "LogKeyValue");

            StfLogger.LogGetEnter(StfLogLevel.Info, "MyTestProperty");
            StfLogger.LogGetExit(StfLogLevel.Info, "MyTestProperty", StfLogger);
            StfLogger.LogSetEnter(StfLogLevel.Info, "MyTestProperty", StfLogger);
            StfLogger.LogSetExit(StfLogLevel.Info, "MyTestProperty", StfLogger);

            StfLogger.LogAutomationIdObject(StfLogLevel.Internal, StfLogger, "Using StfLogger as AID for test");

            StfLogger.SetRunStatus();
        }
Пример #10
0
 public void TestMethodExceptionThrownInTestIsCaughtInCleanup()
 {
     StfLogger.LogInfo("This is a message before assert failed exception error");
     throw new AssertFailedException();
 }
Пример #11
0
 public void TestLogXmlMessage()
 {
     StfLogger.LogInfo("Using PrettyXml - per LogXmlMessage");
     StfLogger.LogXmlMessage(@"<xmltags><xmltag>Line 1 </xmltag><xmltag>Six Space indent</xmltag></xmltags>");
 }
Пример #12
0
 public void TestInitialize()
 {
     StfLogger.LogInfo("DatadrivenStfLoggerTest TestInitialize");
     StfAssert.EnableNegativeTesting = true;
 }
Пример #13
0
 public void TestCleanup()
 {
     StfLogger.LogInfo("DatadrivenStfLoggerTest TestCleanup");
     StfAssert.ResetStatistics();
 }
Пример #14
0
 public void DatadrivenLoggerTest10Lines()
 {
     StfLogger.LogInfo($"Iteration [{DateTime.Now}]");
 }
Пример #15
0
 public void TestInitialize()
 {
     StfAssert.EnableNegativeTesting = true;
     StfLogger.LogInfo("UnitTestStfAsserts TestInitialize");
 }
Пример #16
0
 public void TestCleanup()
 {
     // Setting to true again resets the failure count
     StfAssert.ResetStatistics();
     StfLogger.LogInfo("UnitTestStfAsserts TestCleanup");
 }