NUnit.Framework.Assert.Throws(System.Type, NUnit.Framework.TestDelegate)

Here are the examples of the csharp api class NUnit.Framework.Assert.Throws(System.Type, NUnit.Framework.TestDelegate) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
		public void NoExceptionThrown()
		{
			expectedMessage =
				"  Expected: <System.ArgumentException>" + Environment.NewLine +
				"  But was:  null" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsNothing);
#else
			Assert.Throws( typeof(ArgumentException),
				new TestDelegate( TestDelegates.ThrowsNothing ) );
#endif
		}

2. Example

View license
[Test]
		public void CorrectExceptionThrown()
		{
#if NET_2_0
            Assert.Throws(typeof(ArgumentException), TestDelegates.ThrowsArgumentException);
            Assert.Throws(typeof(ArgumentException),
                delegate { throw new ArgumentException(); });

            Assert.Throws<ArgumentException>(
                delegate { throw new ArgumentException(); });
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsArgumentException);

            // Without cast, delegate is ambiguous before C# 3.0.
            Assert.That((TestDelegate)delegate { throw new ArgumentException(); },
                    Throws.Exception.TypeOf<ArgumentException>() );
            //Assert.Throws( Is.TypeOf(typeof(ArgumentException)),
            //        delegate { throw new ArgumentException(); } );
#else
			Assert.Throws(typeof(ArgumentException),
				new TestDelegate( TestDelegates.ThrowsArgumentException ) );
#endif
        }

3. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
		public void NoExceptionThrown()
		{
			expectedMessage =
				"  Expected: <System.ArgumentException>" + Environment.NewLine +
				"  But was:  null" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsNothing);
#else
			Assert.Throws( typeof(ArgumentException),
				new TestDelegate( TestDelegates.ThrowsNothing ) );
#endif
		}

4. Example

View license
[Test,ExpectedException(typeof(AssertionException))]
        public void DerivedExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.Exception>" + Environment.NewLine +
                "  But was:  <System.ArgumentException> (myMessage" + Environment.NewLine +
                "Parameter name: myParam)" + Environment.NewLine;
            matchType = MessageMatch.StartsWith;

#if CLR_2_0 || CLR_4_0
            Assert.Throws<Exception>(TestDelegates.ThrowsArgumentException);
#else
            Assert.Throws( typeof(Exception),
				new TestDelegate( TestDelegates.ThrowsArgumentException) );
#endif
        }

5. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
        public void UnrelatedExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.ArgumentException>" + Environment.NewLine +
                "  But was:  <System.ApplicationException>" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsApplicationException);
#else
			Assert.Throws( typeof(ArgumentException),
				new TestDelegate(TestDelegates.ThrowsApplicationException) );
#endif
        }

6. Example

View license
[Test]
		public void CorrectExceptionThrown()
		{
#if NET_2_0
            Assert.Throws(typeof(ArgumentException), TestDelegates.ThrowsArgumentException);
            Assert.Throws(typeof(ArgumentException),
                delegate { throw new ArgumentException(); });

            Assert.Throws<ArgumentException>(
                delegate { throw new ArgumentException(); });
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsArgumentException);

            // Without cast, delegate is ambiguous before C# 3.0.
            Assert.That((TestDelegate)delegate { throw new ArgumentException(); },
                    Throws.Exception.TypeOf<ArgumentException>() );
            //Assert.Throws( Is.TypeOf(typeof(ArgumentException)),
            //        delegate { throw new ArgumentException(); } );
#else
			Assert.Throws(typeof(ArgumentException),
				new TestDelegate( TestDelegates.ThrowsArgumentException ) );
#endif
        }

7. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
        public void BaseExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.ArgumentException>" + Environment.NewLine +
                "  But was:  <System.Exception>" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsSystemException);
#else
            Assert.Throws( typeof(ArgumentException),
                new TestDelegate( TestDelegates.ThrowsSystemException) );
#endif
        }

8. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
        public void UnrelatedExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.ArgumentException>" + Environment.NewLine +
                "  But was:  <System.ApplicationException>" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsApplicationException);
#else
			Assert.Throws( typeof(ArgumentException),
				new TestDelegate(TestDelegates.ThrowsApplicationException) );
#endif
        }

9. Example

View license
[Test,ExpectedException(typeof(AssertionException))]
        public void DerivedExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.Exception>" + Environment.NewLine +
                "  But was:  <System.ArgumentException>" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<Exception>(TestDelegates.ThrowsArgumentException);
#else
            Assert.Throws( typeof(Exception),
				new TestDelegate( TestDelegates.ThrowsArgumentException) );
#endif
        }

10. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
		public void NoExceptionThrown()
		{
			expectedMessage =
				"  Expected: <System.ArgumentException>" + Environment.NewLine +
				"  But was:  null" + Environment.NewLine;
#if CLR_2_0 || CLR_4_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsNothing);
#else
			Assert.Throws( typeof(ArgumentException),
				new TestDelegate( TestDelegates.ThrowsNothing ) );
#endif
		}

11. Example

View license
[Test,ExpectedException(typeof(AssertionException))]
        public void DerivedExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.Exception>" + Environment.NewLine +
                "  But was:  <System.ArgumentException>" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<Exception>(TestDelegates.ThrowsArgumentException);
#else
            Assert.Throws( typeof(Exception),
				new TestDelegate( TestDelegates.ThrowsArgumentException) );
#endif
        }

12. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
        public void BaseExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.ArgumentException>" + Environment.NewLine +
                "  But was:  <System.Exception>" + Environment.NewLine;
#if NET_2_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsSystemException);
#else
            Assert.Throws( typeof(ArgumentException),
                new TestDelegate( TestDelegates.ThrowsSystemException) );
#endif
        }

13. Example

View license
[Test]
		public void CorrectExceptionThrown()
        {
#if CLR_2_0 || CLR_4_0
            Assert.Throws(typeof(ArgumentException), TestDelegates.ThrowsArgumentException);
            Assert.Throws(typeof(ArgumentException),
                delegate { throw new ArgumentException(); });

            Assert.Throws<ArgumentException>(
                delegate { throw new ArgumentException(); });
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsArgumentException);

            // Without cast, delegate is ambiguous before C# 3.0.
            Assert.That((TestDelegate)delegate { throw new ArgumentException(); },
                    Throws.Exception.TypeOf<ArgumentException>() );
            //Assert.Throws( Is.TypeOf(typeof(ArgumentException)),
            //        delegate { throw new ArgumentException(); } );
#else
			Assert.Throws(typeof(ArgumentException),
				new TestDelegate( TestDelegates.ThrowsArgumentException ) );
#endif
        }

14. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
        public void BaseExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.ArgumentException>" + Environment.NewLine +
                "  But was:  <System.Exception> (my message)" + Environment.NewLine;
            matchType = MessageMatch.StartsWith;

#if CLR_2_0 || CLR_4_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsSystemException);
#else
            Assert.Throws( typeof(ArgumentException),
                new TestDelegate( TestDelegates.ThrowsSystemException) );
#endif
        }

15. Example

View license
[Test, ExpectedException(typeof(AssertionException))]
        public void UnrelatedExceptionThrown()
        {
            expectedMessage =
                "  Expected: <System.ArgumentException>" + Environment.NewLine +
                "  But was:  <System.ApplicationException> (my message)" + Environment.NewLine;
            matchType = MessageMatch.StartsWith;

#if CLR_2_0 || CLR_4_0
            Assert.Throws<ArgumentException>(TestDelegates.ThrowsApplicationException);
#else
			Assert.Throws( typeof(ArgumentException),
				new TestDelegate(TestDelegates.ThrowsApplicationException) );
#endif
        }

16. Example

Project: designscript-archive
Source File: WhileTest.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T02_AssociativeBlock_Negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"[Associative]
{
    i = 0;
    temp = 1;
    while ( i <= 5)
	{
	    temp = temp + 1;
         i = i + 1;
    }
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
            });

        }

17. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_17()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"]a = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

18. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_Tailer_03()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"a! = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

19. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T018_LanguageBlockScope_ImperativeNestedImperaive_Function()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"[Imperative]
{
	def foo : int(a : int, b : int)
	{
		return = a + b;
	}
		[Imperative]	
	{
	x = 10;
	y = 20;
	z = foo (x, y);
	}
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
                // Assert.IsTrue((Int64)mirror.GetValue("z").Payload == 30);
            });
        }

20. Example

View license
[Test]
        public void T61_Defect_1467546_8()
        {
            String code =
            @"
class A
{
    static def foo()
    {
        return = 1;
    }
}
x = 1;
a = A.foo()
b = a + 1;
 
";
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                Object n1 = null;
                thisTest.RunScriptSource(code);
                thisTest.Verify("test", n1);
            });
        }

21. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_11()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @")a = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

22. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_Tailer_30()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"a. = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

23. Example

Project: designscript-archive
Source File: WhileTest.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T04_OutsideBlock_Negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"i = 0;    
temp = 1;
while( i < 5 )
{
    temp = temp + 1;
    i = i + 1;
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
            });

        }

24. Example

View license
[Test]
        [Category("SmokeTest")]
        public void T54_Associative_Nested_deffect_1467063()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
[Associative]
{        a = 4;
         b = 2;
     [Associative]
	 {
       b = a + 4;
     }
}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

25. Example

Project: designscript-archive
Source File: Class.cs
View license
[Test]
        [Category("SmokeTest")]
        public void Z030_Class_Instance_Name_Same_As_Class_Negative_2()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
class A
{
    a : var;
	constructor A ()
	{
	    a = 1;
	}
}
A = A.A();
t = A.a;
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

26. Example

Project: designscript-archive
Source File: BlockSyntax.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T19_Imperative_Nested()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
[Imperative]
{
   a=1;
   [Imperative]
    {
    b=a+1;
    }
}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

27. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_Tailer_18()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"a{ = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

28. Example

Project: designscript-archive
Source File: BlockSyntax.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T01_TestImpInsideImp()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
[Imperative]
{
    x = 5;
    [Imperative]
    {
        y = 5;
    }
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
                // thisTest.Verify("x", 5);
                // thisTest.Verify("y", 5);
            });
        }

29. Example

View license
[Test]
        [Category("SmokeTest")]
        public void TV21_Function_With_Illegal_Syntax_2()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"b;
[Imperative]
{
	def foo : int(a ; int)
	{
		return = a + 1;
	}
	
	b = foo( 9 );
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
            });
        }

30. Example

View license
[Test]
        public void T13_NegativeTest_UsingMemFunctionNameAsMemVarName_Class()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
def foo:int(x:int)
{
	return = x;
}
class A
{
	memFoo : var;
	def memFoo()
	{
		return = 2;
	}
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

31. Example

Project: designscript-archive
Source File: ForLoop.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T01_TestNegativeSyntax_Negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"[Imperative]
{
	a = { 4, 5, 3 };
	x = 0;
 
	for { y in a }
	{
	    x = x + 1;
    }
} ";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
            });
        }

32. Example

View license
[Test]
        [Category("SmokeTest")]
        public void T52_Negative_Associative_Syntax()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
[Imperative]
{
	x = 1;
	y = {Associative]
	{
	   return = x + 1;
	}
}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

33. Example

View license
[Test]
        [Category("Negative")]
        public void T56_Defect_1467242_2()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
@"
a = {0, 1};
for(i in a)
{
    a[i] = 0;
}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

34. Example

Project: designscript-archive
Source File: ForLoop.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T02_TestNegativeUsage_InAssociativeBlock_Negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"[Associative]
{
	a = { 2, 3 };
	x = 1;
	
	for( y in a )
	{
		x = x + 1;
	}
}
	";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
            });
        }

35. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_05()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"$a = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

36. Example

View license
[Test]
        [Category("SmokeTest")]
        public void T63_Language_specifier_invalid_1467065_2()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
[imperative]
{    a= 1;
}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

37. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_03()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"!a = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

38. Example

Project: designscript-archive
Source File: IfElseTest.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T33_IfElseSyntax_negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
                {
                    string src = @"[Imperative]
{
    if(0)
	{
		b = 1;
	}
	elseif (0) { c = 2; }
	else { c = 3;}
	else {c = 4};
	
		
} 
 
 ";
                    ExecutionMirror mirror = thisTest.RunScriptSource(src);
                });
        }

39. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_Tailer_29()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"a, = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

40. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_19()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"}a = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

41. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_29()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"<a = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

42. Example

Project: designscript-archive
Source File: TestClass.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T16_Class_Constructor_Negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
class A
{ 
	x : int;
	
	constructor A (i)
	{
		x = i;		
		return = { x, i};
	}
	
	
}
a1 = A.A(1);
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

43. Example

Project: designscript-archive
Source File: ForLoop.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T04_TestNegativeUsage_OutsideBlock_Negative()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string src = @"
	a = { 2,3 };
	x = 1;
	
	for( y in a )
	{
		x = x + 1;
	}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(src);
            });
        }

44. Example

View license
[Test]
        public void T61_Defect_1467546_6()
        {
            String code =
            @"
x = 1;
a = 10
b = a + 1;
 
";
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                Object n1 = null;
                thisTest.RunScriptSource(code);
                thisTest.Verify("test", n1);
            });
        }

45. Example

Project: designscript-archive
Source File: Class.cs
View license
[Test]
        [Category("SmokeTest")]
        public void Z027_Defect_1461365()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
class A
{
    a : int;	
}
class B extends B // negative case
{
    b : int;
}
b1 = B.B();
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

46. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_Tailer_02()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"a` = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

47. Example

View license
[Test]
        public void T12_NegativeTest_UsingGlobalFunctionNameAsMemVarName_Class()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
def foo:int(x:int)
{
	return = x;
}
class A
{
	foo : var;
}";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

48. Example

Project: designscript-archive
Source File: TestImport.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T021_Defect_1457354()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                string code = @"
import (""c:\wrongPath\test.ds"");
a = 1;
b = a * 2;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

49. Example

View license
[Test]
        [Category("Negative")]
        public void T56_Defect_1467242_3()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
@"
i = 0;
while(i < 3)
{
    i = i + 1;
}
";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }

50. Example

Project: designscript-archive
Source File: TestScope.cs
View license
[Test]
        [Category("SmokeTest")]
        public void T050_Test_Identifier_Name_Tailer_25()
        {
            Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () =>
            {
                String code =
                 @"a"" = 1;";
                ExecutionMirror mirror = thisTest.RunScriptSource(code);
            });
        }