Пример #1
0
        static void TestAddNodeAfter(TestCaseNode testCase, LinkedList linkedList)
        {
            try
            {
                var prevNode = linkedList.FindNode(testCase.ExpectedValue);
                linkedList.AddNodeAfter(prevNode, testCase.Value);

                if (prevNode.NextNode.Value == testCase.Value)
                {
                    Console.WriteLine("ТЕСТ ПРОЙДЕН");
                }
                else
                {
                    Console.WriteLine("ТЕСТ НЕ ПРОЙДЕН");
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == testCase.ExpectedException)
                {
                    Console.WriteLine("ТЕСТ ПРОЙДЕН");
                }
                else
                {
                    Console.WriteLine("ТЕСТ НЕ ПРОЙДЕН");
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Z80TestParser.testCase"/>.
        /// <para>
        /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
        /// on <paramref name="context"/>.
        /// </para>
        /// </summary>
        /// <param name="context">The parse tree.</param>
        /// <return>The visitor result.</return>
        public override object VisitTestCase(Z80TestParser.TestCaseContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }
            var node = new TestCaseNode(context);

            foreach (var expr in context.expr())
            {
                node.Expressions.Add((ExpressionNode)VisitExpr(expr));
            }
            foreach (var id in context.IDENTIFIER())
            {
                node.PortMocks.Add(new IdentifierNameNode(id));
            }
            return(node);
        }
 /// <summary>
 /// Visits a single test case
 /// </summary>
 /// <param name="line">Line to add the tag for</param>
 /// <param name="context">TestCaseNode to visit</param>
 /// <param name="lineNo">Current line numer</param>
 /// <param name="collectedSpans">Collection of spans found</param>
 private void Visit(ITextSnapshotLine line, TestCaseNode context, int lineNo, List <TagSpan <Z80TestTokenTag> > collectedSpans)
 {
     if (context == null ||
         lineNo < context.Span.StartLine ||
         lineNo > context.Span.EndLine)
     {
         return;
     }
     Visit(line, context.CaseKeywordSpan, lineNo, collectedSpans, Z80TestTokenType.Keyword);
     Visit(line, context.PortMockKeywordSpan, lineNo, collectedSpans, Z80TestTokenType.Keyword);
     foreach (var expr in context.Expressions)
     {
         Visit(line, expr, lineNo, collectedSpans);
     }
     foreach (var id in context.PortMocks)
     {
         Visit(line, id.Span, lineNo, collectedSpans, Z80TestTokenType.Identifier);
     }
 }
Пример #4
0
		private void SetTreeNodes(IList<ReportSuite> reportSuites)
		{
			foreach (ReportSuite suite in reportSuites)
			{
				ContainerNode suitenode = new ContainerNode(suite.Name);
				suitenode.Name = suite.Name;
				foreach (ReportAssembly reportAssembly in suite.Assemblies)
				{
					ContainerNode assemblyNode = new ContainerNode(reportAssembly.Location);
					assemblyNode.Name = reportAssembly.Location;
					foreach (TestClass testClass in reportAssembly.TestClasses)
					{
						ContainerNode testClassNode = new ContainerNode(testClass.Name);
						testClassNode.Name = testClass.TestNamespace;
						foreach (Test test in testClass.Tests)
						{
							bool testPassed = test.Passed;
							string testName = test.Name;
							TestCaseNode testNode = new TestCaseNode(testName);
							if (!testPassed)
							{
								FailStateNode dummy = new DummyTreeNode("-");
								testNode.Nodes.Add(dummy);
								testNode.NotifyChildAttached(dummy);
							}
							testClassNode.Nodes.Add(testNode);
							testClassNode.NotifyChildAttached(testNode);
						}
						assemblyNode.Nodes.Add(testClassNode);
						testClassNode.NotifyAttachedToParent();
					}
					suitenode.Nodes.Add(assemblyNode);
					assemblyNode.NotifyAttachedToParent();
				}
				reportTreeView.Nodes.Add(suitenode);
			}

		}
Пример #5
0
			public void Initialize(IList<ReportSuite> reportSuites, TestCaseNode node)
			{
				//set private variables based on the contents of the tree node
				mySuiteName = node.Parent.Parent.Parent.Text;
				myAssemblyLocation = node.Parent.Parent.Text;
				myTestClassName = node.Parent.Text;
				myTestNamespace = node.Parent.Name;
				myTestName = node.Text;

				//with the information taken from the node, get the Result and Content information
				//by walking through the reportsuites structure.
				foreach (ReportSuite suite in reportSuites)
				{
					if (suite.Name == mySuiteName)
					{
						foreach (ReportAssembly reportAssembly in suite.Assemblies)
						{
							if (reportAssembly.Location == myAssemblyLocation)
							{
								foreach (TestClass testClass in reportAssembly.TestClasses)
								{
									if (testClass.Name == myTestClassName && testClass.TestNamespace == myTestNamespace)
									{
										foreach (Test test in testClass.Tests)
										{
											if (test.Name == myTestName)
											{
												myResult = test.Result;
												myContent = test.Content;
												myBaseFileName = String.Concat(myTestNamespace, ".", myTestClassName, ".", myTestName);
												initialized = true;
											}
										}
									}
								}
							}
						}
					}
				}
			}