~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to src/ConsoleRunner/tests/TestNameParserTests.cs

  • Committer: Charlie Poole
  • Date: 2011-03-14 17:55:29 UTC
  • Revision ID: charlie@nunit.org-20110314175529-cnnn24ltmcdkyg4y
Allow test names containing comma-separated arguments in the -run option

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ****************************************************************
 
2
// Copyright 2011, Charlie Poole
 
3
// This is free software licensed under the NUnit license. You may
 
4
// obtain a copy of the license at http://nunit.org
 
5
// ****************************************************************
 
6
 
 
7
using System;
 
8
using NUnit.Framework;
 
9
 
 
10
namespace NUnit.ConsoleRunner.Tests
 
11
{
 
12
    public class TestNameParserTests
 
13
    {
 
14
        [TestCase("Test.Namespace.Fixture.Method")]
 
15
        [TestCase("Test.Namespace.Fixture.Method,")]
 
16
        [TestCase("  Test.Namespace.Fixture.Method  ")]
 
17
        [TestCase("  Test.Namespace.Fixture.Method  ,")]
 
18
        [TestCase("Test.Namespace.Fixture.Method()")]
 
19
        [TestCase("Test.Namespace.Fixture.Method(\"string,argument\")")]
 
20
        [TestCase("Test.Namespace.Fixture.Method(1,2,3)")]
 
21
        [TestCase("Test.Namespace.Fixture.Method<int,int>()")]
 
22
        [TestCase("Test.Namespace.Fixture.Method(\")\")")]
 
23
        public void SingleName(string name)
 
24
        {
 
25
            string[] names = TestNameParser.Parse(name);
 
26
            Assert.AreEqual(1, names.Length);
 
27
            Assert.AreEqual(name.Trim(new char[] { ' ', ',' }), names[0]);
 
28
        }
 
29
 
 
30
        [TestCase("Test.Namespace.Fixture.Method1", "Test.Namespace.Fixture.Method2")]
 
31
        [TestCase("Test.Namespace.Fixture.Method1", "Test.Namespace.Fixture.Method2,")]
 
32
        [TestCase("Test.Namespace.Fixture.Method1(1,2)", "Test.Namespace.Fixture.Method2(3,4)")]
 
33
        [TestCase("Test.Namespace.Fixture.Method1(\"(\")", "Test.Namespace.Fixture.Method2(\"<\")")]
 
34
        public void TwoNames(string name1, string name2)
 
35
        {
 
36
            char[] delims = new char[] { ' ', ',' };
 
37
            string[] names = TestNameParser.Parse(name1 + "," + name2);
 
38
            Assert.AreEqual(2, names.Length);
 
39
            Assert.AreEqual(name1.Trim(delims), names[0]);
 
40
            Assert.AreEqual(name2.Trim(delims), names[1]);
 
41
        }
 
42
    }
 
43
}