public Task Should_Write_Exception_With_Shortened_Types() { // Given var console = new TestConsole().Width(1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When var result = console.WriteNormalizedException(dex, ExceptionFormats.ShortenTypes); // Then return(Verifier.Verify(result)); }
public Task Should_Write_Exceptions_With_Generic_Type_Parameters_In_Callsite_As_Expected() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.ThrowWithGenericInnerException()); // When var result = console.WriteNormalizedException(dex); // Then return(Verifier.Verify(result)); }
public Task Should_Write_Exception_With_Inner_Exception() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.ThrowWithInnerException()); // When var result = console.WriteNormalizedException(dex); // Then return(Verifier.Verify(result)); }
public Task Should_Write_Exception() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When var result = console.WriteNormalizedException(dex); // Then return(Verifier.Verify(result)); }
public void Should_Write_Exception_With_Shortened_Methods() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When var result = console.WriteExceptionAndGetLines(dex, ExceptionFormats.ShortenMethods); // Then result.Length.ShouldBe(4); result[0].ShouldBe("System.InvalidOperationException: Throwing!"); result[1].ShouldBe(" at MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn"); result[2].ShouldBe(" at <Should_Write_Exception_With_Shortened_Methods>b__2_0() in /xyz/ExceptionTests.cs:nn"); result[3].ShouldBe(" at GetException(Action action) in /xyz/ExceptionTests.cs:nn"); }
public void Should_Write_Exception() { // Given var console = new PlainConsole(width: 1024); var dex = GetException(() => TestExceptions.MethodThatThrows(null)); // When var result = console.WriteExceptionAndGetLines(dex); // Then result.Length.ShouldBe(4); result[0].ShouldBe("System.InvalidOperationException: Throwing!"); result[1].ShouldBe(" at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn"); result[2].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.<>c.<Should_Write_Exception>b__0_0() in /xyz/ExceptionTests.cs:nn"); result[3].ShouldBe(" at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn"); }
/// <summary> /// Adds extensions to the extension array list. This function handles the starting /// node in the XML document tree with XML_EXTENSION_TAG. Each extension is parsed /// for name, id, and location. /// </summary> /// <param name="m_xmlReader">An XmlTextReader instance starting at the XML_EXTENSION_TAG node of the XML document.</param> /// <remarks> /// Author(s): teejay /// Revision: 1.0 /// Modified: 6/04/2003 /// </remarks> private void AddExtension(XmlTextReader m_xmlReader) { // The extension will refer to a new dependency file to load which // will be read from this new XmlTextReader... XmlTextReader m_newReader; string m_elementName; string m_elementValue; // instantaite a new struct to store the data... ExtensionData m_extensionData = new ExtensionData( ); try { while (m_xmlReader.Read( )) { switch (m_xmlReader.NodeType) { case XmlNodeType.EndElement: if (m_xmlReader.Name == XML_EXTENSION_TAG) { goto finished; } break; case XmlNodeType.Element: // get the name of the element... m_elementName = m_xmlReader.Name; // attempt to read the actual value of the element... m_xmlReader.Read( ); if (m_xmlReader.NodeType == XmlNodeType.EndElement) { // no value exists for this element... m_elementValue = ""; } else { m_elementValue = m_xmlReader.Value; } if (m_elementName == XML_EXTENSION_ID_TAG) { m_extensionData.id = m_elementValue; } if (m_elementName == XML_EXTENSION_NAME_TAG) { m_extensionData.name = m_elementValue; } if (m_elementName == XML_EXTENSION_LOCATION_TAG) { if (Directory.Exists(m_elementValue)) { m_extensionData.location = m_elementValue; } else { m_extensionData.location = System.IO.Path.GetFullPath(System.IO.Path.GetFullPath(m_dependencyLocation) + "\\" + m_elementValue); } } break; } } finished: // add the extension to the array... m_extensionArray.Add(m_extensionData); // now attempt to load the extended dependency data as part of the current // list of dependencies... m_newReader = LoadDependencyFileLocally(m_extensionData.location + "\\" + m_extensionData.name); // parse dependencies on this extended dependency file... ParseDependencies(m_newReader); } catch (DependencyFileDoesNotExistException e) { TestExceptions.printException(e); throw e; } }
/// <summary> /// Parses command line arguments passed to the test executable. /// </summary> /// <param name="args">The command line arguments string array passed from the entrypoint procedure.</param> /// <remarks> /// Author(s): teejay /// Revision: 1.0 /// Modified: 6/04/2003 /// </remarks> public virtual void parseCommandLineArgs(string[] args) { char[] argumentArray; string testCaseID = "Unprovided"; string dependencyFile = DEFAULT_DEPENDENCY_FILE; try { if (args.Length == 0) { throw new NoTestException( ); } else { // go through all the arguments passed on the commandline... for (int argCount = 0; argCount < args.Length; argCount++) { argumentArray = args[argCount].ToCharArray( ); if (args.Length > 1) { if ((argumentArray[0] == '-') || (argumentArray[0] == '/') && (argCount != 0)) { // switch based on switch (argumentArray[1]) { case 'd': // check to ensure that a dependency exists... if ((argCount + 1) >= args.Length) { throw new NoDependencyFileException( ); } else { // set to use the alternate dependency file specified... dependencyFile = args[argCount + 1]; } break; case 'a': System.Diagnostics.Debugger.Break( ); break; case 'c': Log.Log.color = true; break; case 'l': if ((argCount + 1) >= args.Length) { throw new Exception("No log file name specified with 'l' option."); } else { logFile = args[argCount + 1]; // set to use the log file specified... Log.Log.logWriter = new StreamWriter(logFile); } break; case 'o': if ((argCount + 1) >= args.Length) { throw new Exception("No output path specified with 'o' option."); } else { // set to use the log file specified... OutputPath = args[argCount + 1]; } break; case 's': Log.Log.logSilent = true; break; case 'v': verbose = true; break; case 'x': if ((argCount + 1) >= args.Length) { throw new Exception("No file specified with 'l' option."); } else { // set to use the log file specified... disableTestsLocation = args[argCount + 1]; DisableTests = getDisabledTests(disableTestsLocation); } break; case 'z': // create an arraylist containing all the test specific parameters... for (int count = argCount + 1; count < args.Length; count++) { testSpecificParameters.Add(args[count]); } break; } } } } } if (verbose) { Log.Log.printTestStatus("<< Test Framework V. 1.0 Running >>\n"); } if (verbose) { if (dependencyFile != DEFAULT_DEPENDENCY_FILE) { Log.Log.printSuccess("Using Alternate Dependency", dependencyFile); } } // set the test case ID... testCaseID = args[0]; performPreRunTasks( ); DisabledTest currentDisabledTest = null; foreach (DisabledTest disabledTest in DisableTests) { if (disabledTest.testID == testCaseID) { currentDisabledTest = disabledTest; } } if (currentDisabledTest == null) { // perform the test run... performRun(testCaseID, dependencyFile); // perform post run tasks... performPostRunTasks( ); } else { Log.Log.printSuccess("TEST DISABLED", "The test [" + testCaseID + "] has been disabled using a disable file.\n" + "REASON: [" + currentDisabledTest.reason + "]"); } } catch (NoTestException e) { TestExceptions.printException(e); printCommandLineHelp( ); // rethrow the exception to be caught again... throw e; } catch (TestExceptions e) { // rethrow the exception to be caught again... throw e; } }