source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/lib/NUnit/NUnit-2.5.10.11092/samples/jsharp/failures/JSharpTest.jsl@ 1146

Last change on this file since 1146 was 1146, checked in by Sam Habiel, 13 years ago

Initial Import of BMX4

File size: 1.8 KB
Line 
1// ****************************************************************
2// This is free software licensed under the NUnit license. You
3// may obtain a copy of the license as well as information regarding
4// copyright ownership at http://nunit.org/?p=license&r=2.4.
5// ****************************************************************
6
7package NUnit.Samples;
8
9import System.*;
10import NUnit.Framework.Assert;
11
12/** @attribute NUnit.Framework.TestFixture() */
13public class SimpleJSharpTest
14{
15 protected int fValue1;
16 protected int fValue2;
17
18 /** @attribute NUnit.Framework.SetUp() */
19 public void Init()
20 {
21 fValue1 = 2;
22 fValue2 = 3;
23 }
24
25 /** @attribute NUnit.Framework.Test() */
26 public void Add()
27 {
28 int result= fValue1 + fValue2;
29 Assert.AreEqual(6,result, "Expected Failure");
30 }
31
32 /** @attribute NUnit.Framework.Test() */
33 public void DivideByZero()
34 {
35 int zero= 0;
36 int result = 8/zero;
37 KeepCompilerFromWarning(result); // never executed, here to avoid compiler warning that result is unused.
38 }
39
40 /** @attribute NUnit.Framework.Test() */
41 public void Equals()
42 {
43 Assert.AreEqual(12, 12, "Integer");
44 Assert.AreEqual(new Long(12), new Long(13), "Long");
45 Assert.AreEqual('a', 'a', "Char");
46 Assert.AreEqual(new Integer(12), new Integer(12), "Integer Object Cast");
47
48 Assert.AreEqual(12, 13, "Expected Failure (Integer)");
49 Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double).");
50 }
51
52 /** @attribute NUnit.Framework.Test() */
53 /** @attribute NUnit.Framework.Ignore("ignored test") */
54 public void IgnoredTest()
55 {
56 throw new InvalidCastException();
57 }
58
59 // A useless function, designed to avoid a compiler warning in the the DivideByZero test.
60 private int KeepCompilerFromWarning(int dummy)
61 {
62 return dummy;
63 }
64
65}
Note: See TracBrowser for help on using the repository browser.