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); }
private void HelperUnaryAssert( UnaryStringAssert unaryStringAssert, string argument, bool expected) { Func <string, string, bool> stringAssertFunction; switch (unaryStringAssert) { // Empty case UnaryStringAssert.StringEmpty: stringAssertFunction = StfAssert.StringEmpty; break; case UnaryStringAssert.StringNotEmpty: stringAssertFunction = StfAssert.StringNotEmpty; break; default: throw new ArgumentOutOfRangeException(nameof(unaryStringAssert), unaryStringAssert, null); } var argumentValue = GetStringValueUnfoldEmptyNull(argument); var testDescription = $"{unaryStringAssert}({argumentValue})"; StfLogger.LogSubHeader($"Unit Testing: {testDescription} --> Expecting {expected}"); var retVal = stringAssertFunction(testDescription, argument); if (expected != retVal ) { StfLogger.LogSubHeader($"Unit Test Found an error for {testDescription}..."); } if (expected) { Assert.IsTrue(retVal, "Unit Test Result"); } else { Assert.IsFalse(retVal, "Unit Test Result"); } }
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(); }
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(); }
private void HelperBinaryAssert( BinaryStringAssert binaryStringAssert, string arg1, string arg2, bool expected) { Func <string, string, string, bool> stringAssertFunction; switch ( binaryStringAssert ) { // EQUALS case BinaryStringAssert.StringEquals: stringAssertFunction = StfAssert.StringEquals; break; case BinaryStringAssert.StringEqualsCi: stringAssertFunction = StfAssert.StringEqualsCi; break; case BinaryStringAssert.StringNotEquals: stringAssertFunction = StfAssert.StringNotEquals; break; case BinaryStringAssert.StringNotEqualsCi: stringAssertFunction = StfAssert.StringNotEqualsCi; break; // CONTAINS case BinaryStringAssert.StringContains: stringAssertFunction = StfAssert.StringContains; break; case BinaryStringAssert.StringNotContains: stringAssertFunction = StfAssert.StringDoesNotContain; break; // ENDS WITH case BinaryStringAssert.StringEndsWith: stringAssertFunction = StfAssert.StringEndsWith; break; case BinaryStringAssert.StringDoesNotEndsWith: stringAssertFunction = StfAssert.StringDoesNotEndsWith; break; // STARTS WITH case BinaryStringAssert.StringStartsWith: stringAssertFunction = StfAssert.StringStartsWith; break; case BinaryStringAssert.StringDoesNotStartWith: stringAssertFunction = StfAssert.StringDoesNotStartWith; break; // MATCHES case BinaryStringAssert.StringMatches: stringAssertFunction = StfAssert.StringMatches; break; case BinaryStringAssert.StringDoesNotMatch: stringAssertFunction = StfAssert.StringDoesNotMatch; break; default: throw new ArgumentOutOfRangeException(nameof(binaryStringAssert), binaryStringAssert, null); } var arg1Value = GetStringValueUnfoldEmptyNull(arg1); var arg2Value = GetStringValueUnfoldEmptyNull(arg2); var testDescription = $"{binaryStringAssert}({arg1Value}, {arg2Value})"; StfLogger.LogSubHeader($"Unit Testing: {testDescription} --> Expecting {expected}"); var retVal = stringAssertFunction(testDescription, arg1, arg2); if (expected != retVal) { StfLogger.LogSubHeader($"Unit Test Found an error for {testDescription}..."); } if (expected) { Assert.IsTrue ( retVal, "Unit Test Result"); } else { Assert.IsFalse ( retVal, "Unit Test Result"); } }