Beispiel #1
0
        public void TestCommandLine()
        {
            CLBTester clbt = new CLBTester();

            clbt.AppendFileNameIfNotNull("a");
            Assert.AreEqual(clbt.ToString(), clbt.CommandLine.ToString(), "A1");
        }
        private void CheckVerifyThrowNoEmbeddedDoubleQuotes(CLBTester clbt, string switchName, string parameter,
                                                            bool expectException, Type exceptionType, string id)
        {
            try
            {
                clbt.VerifyThrowNoEmbeddedDoubleQuotes(switchName, parameter);
            }
            catch (Exception e)
            {
                if (!expectException)
                {
                    Assert.Fail("({0}) Unexpected exception : {1}", id, exceptionType.ToString());
                }
                if (e.GetType() != exceptionType)
                {
                    Assert.Fail("({0}) Expected exception of {1} type but got {2}", id, exceptionType.ToString(), e.ToString());
                }
                return;
            }

            if (expectException)
            {
                Assert.Fail("({0}) Didn't get expected exception {1}", id, exceptionType.ToString());
            }
        }
Beispiel #3
0
        public void TestAppendTextUnquoted()
        {
            CLBTester clbt = new CLBTester();

            clbt.AppendTextUnquoted(null);

            clbt.AppendTextUnquoted("a b");

            Assert.AreEqual("a b", clbt.ToString(), "A1");
        }
Beispiel #4
0
        public void TestVerifyThrowNoEmbeddedDoubleQuotes1()
        {
            CLBTester clbt = new CLBTester();

            clbt.VerifyThrowNoEmbeddedDoubleQuotes(null, null);
            clbt.VerifyThrowNoEmbeddedDoubleQuotes("", null);
            clbt.VerifyThrowNoEmbeddedDoubleQuotes(null, "");
            clbt.VerifyThrowNoEmbeddedDoubleQuotes(" ", "");
            clbt.VerifyThrowNoEmbeddedDoubleQuotes("", " ");
            clbt.VerifyThrowNoEmbeddedDoubleQuotes("\"abc\"", "");
            clbt.VerifyThrowNoEmbeddedDoubleQuotes("x\"y", "");
            clbt.VerifyThrowNoEmbeddedDoubleQuotes("\'\'", "\'\'");
        }
Beispiel #5
0
        public void TestAppendSpaceIfNotEmpty()
        {
            CLBTester clbt = new CLBTester();

            clbt.AppendSpaceIfNotEmpty();

            Assert.AreEqual(String.Empty, clbt.ToString(), "A1");

            clbt.AppendFileNameIfNotNull("a");
            clbt.AppendFileNameIfNotNull("b");

            Assert.AreEqual("a b", clbt.ToString(), "A2");
        }
Beispiel #6
0
        public void TestAppendFileNameWithQuoting1()
        {
            CLBTester clbt = new CLBTester();

            clbt.AppendFileNameWithQuoting(null);

            Assert.AreEqual(String.Empty, clbt.ToString(), "A1");

            clbt.AppendFileNameWithQuoting("abc abc");

            Assert.AreEqual("\"abc abc\"", clbt.ToString(), "A2");

            clbt = new CLBTester();

            clbt.AppendFileNameWithQuoting("abc");

            Assert.AreEqual("abc", clbt.ToString(), "A3");
        }
Beispiel #7
0
        public void TestIsQuotingRequired()
        {
            CLBTester clbt = new CLBTester();

            Assert.AreEqual(false, clbt.IsQuotingRequired(null), "A0");
            Assert.AreEqual(false, clbt.IsQuotingRequired(""), "A1");
            Assert.AreEqual(true, clbt.IsQuotingRequired(" "), "A2");
            Assert.AreEqual(false, clbt.IsQuotingRequired("a"), "A3");
            Assert.AreEqual(true, clbt.IsQuotingRequired("a a"), "A4");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\'\'"), "A5");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\' \'"), "A6");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\"\""), "A7");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\" \""), "A8");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\n\n"), "A9");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\n \n"), "A10");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\t\t"), "A11");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\t \t"), "A12");
            Assert.AreEqual(true, clbt.IsQuotingRequired("a;b"), "A13");
            Assert.AreEqual(true, clbt.IsQuotingRequired("a\u000bc"), "A14");
            Assert.AreEqual(true, clbt.IsQuotingRequired("a\u000cx"), "A15");
            Assert.AreEqual(true, clbt.IsQuotingRequired("\""), "A16");
            Assert.AreEqual(true, clbt.IsQuotingRequired(" abc"), "A17");
        }
Beispiel #8
0
		private void CheckVerifyThrowNoEmbeddedDoubleQuotes(CLBTester clbt, string switchName, string parameter,
				bool expectException, Type exceptionType, string id)
		{
			try
			{
				clbt.VerifyThrowNoEmbeddedDoubleQuotes(switchName, parameter);
			} catch (Exception e) {
				if (!expectException)
					Assert.Fail("({0}) Unexpected exception : {1}", id, exceptionType.ToString());
				if (e.GetType () != exceptionType)
					Assert.Fail("({0}) Expected exception of {1} type but got {2}", id, exceptionType.ToString(), e.ToString());
				return;
			}

			if (expectException)
				Assert.Fail("({0}) Didn't get expected exception {1}", id, exceptionType.ToString());
		}
Beispiel #9
0
		public void TestVerifyThrowNoEmbeddedDoubleQuotes1 ()
		{
			CLBTester clbt = new CLBTester ();

			clbt.VerifyThrowNoEmbeddedDoubleQuotes (null, null);
			clbt.VerifyThrowNoEmbeddedDoubleQuotes ("", null);
			clbt.VerifyThrowNoEmbeddedDoubleQuotes (null, "");
			clbt.VerifyThrowNoEmbeddedDoubleQuotes (" ", "");
			clbt.VerifyThrowNoEmbeddedDoubleQuotes ("", " ");
			clbt.VerifyThrowNoEmbeddedDoubleQuotes ("\"abc\"", "");
			clbt.VerifyThrowNoEmbeddedDoubleQuotes ("x\"y", "");
			clbt.VerifyThrowNoEmbeddedDoubleQuotes ("\'\'", "\'\'");
		}
Beispiel #10
0
		public void TestIsQuotingRequired ()
		{
			CLBTester clbt = new CLBTester ();

			Assert.AreEqual (false, clbt.IsQuotingRequired (null), "A0");
			Assert.AreEqual (false, clbt.IsQuotingRequired (""), "A1");
			Assert.AreEqual (true, clbt.IsQuotingRequired (" "), "A2");
			Assert.AreEqual (false, clbt.IsQuotingRequired ("a"), "A3");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("a a"), "A4");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\'\'"), "A5");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\' \'"), "A6");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\"\""), "A7");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\" \""), "A8");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\n\n"), "A9");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\n \n"), "A10");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\t\t"), "A11");
			Assert.AreEqual (true, clbt.IsQuotingRequired ("\t \t"), "A12");
			Assert.AreEqual (true, clbt.IsQuotingRequired("a;b"), "A13");
			Assert.AreEqual (true, clbt.IsQuotingRequired("a\u000bc"), "A14");
			Assert.AreEqual (true, clbt.IsQuotingRequired("a\u000cx"), "A15");
			Assert.AreEqual (true, clbt.IsQuotingRequired("\""), "A16");
			Assert.AreEqual (true, clbt.IsQuotingRequired(" abc"), "A17");
		}
Beispiel #11
0
		public void TestCommandLine ()
		{
			CLBTester clbt = new CLBTester ();
			clbt.AppendFileNameIfNotNull ("a");
			Assert.AreEqual (clbt.ToString (), clbt.CommandLine.ToString (), "A1");
		}
Beispiel #12
0
		public void TestAppendTextWithQuoting ()
		{
			CLBTester clbt = new CLBTester ();

			clbt.AppendTextWithQuoting (null);

			clbt.AppendTextUnquoted ("a b");

			Assert.AreEqual ("a b", clbt.ToString (), "A1");

			clbt = new CLBTester ();
			clbt.AppendTextWithQuoting ("a");

			Assert.AreEqual ("a", clbt.ToString (), "A2");
		}
Beispiel #13
0
		public void TestAppendSpaceIfNotEmpty ()
		{
			CLBTester clbt = new CLBTester ();

			clbt.AppendSpaceIfNotEmpty ();

			Assert.AreEqual (String.Empty, clbt.ToString (), "A1");

			clbt.AppendFileNameIfNotNull ("a");
			clbt.AppendFileNameIfNotNull ("b");

			Assert.AreEqual ("a b", clbt.ToString (), "A2");
		}
Beispiel #14
0
		public void TestAppendFileNameWithQuoting1 ()
		{
			CLBTester clbt = new CLBTester ();

			clbt.AppendFileNameWithQuoting (null);

			Assert.AreEqual (String.Empty, clbt.ToString (), "A1");

			clbt.AppendFileNameWithQuoting ("abc abc");

			Assert.AreEqual ("\"abc abc\"", clbt.ToString (), "A2");

			clbt = new CLBTester ();

			clbt.AppendFileNameWithQuoting ("abc");

			Assert.AreEqual ("abc", clbt.ToString (), "A3");
		}