source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/lib/NUnit/NUnit-2.5.10.11092/samples/csharp/failures/CSharpTest.cs@ 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
7namespace NUnit.Samples
8{
9 using System;
10 using NUnit.Framework;
11
12 /// <summary>Some simple Tests.</summary>
13 ///
14 [TestFixture]
15 public class SimpleCSharpTest
16 {
17 /// <summary>
18 ///
19 /// </summary>
20 protected int fValue1;
21 /// <summary>
22 ///
23 /// </summary>
24 protected int fValue2;
25
26 /// <summary>
27 ///
28 /// </summary>
29 [SetUp] public void Init()
30 {
31 fValue1= 2;
32 fValue2= 3;
33 }
34
35 /// <summary>
36 ///
37 /// </summary>
38 ///
39 [Test] public void Add()
40 {
41 double result= fValue1 + fValue2;
42 // forced failure result == 5
43 Assert.AreEqual(6, result, "Expected Failure.");
44 }
45
46 /// <summary>
47 ///
48 /// </summary>
49 ///
50 [Test] public void DivideByZero()
51 {
52 int zero= 0;
53 int result= 8/zero;
54 }
55
56 /// <summary>
57 ///
58 /// </summary>
59 ///
60 [Test] public void Equals()
61 {
62 Assert.AreEqual(12, 12, "Integer");
63 Assert.AreEqual(12L, 12L, "Long");
64 Assert.AreEqual('a', 'a', "Char");
65 Assert.AreEqual((object)12, (object)12, "Integer Object Cast");
66
67 Assert.AreEqual(12, 13, "Expected Failure (Integer)");
68 Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double).");
69 }
70
71 [Test]
72 [ExpectedException(typeof(InvalidOperationException))]
73 public void ExpectAnException()
74 {
75 throw new InvalidCastException();
76 }
77
78 [Test]
79 [Ignore("ignored test")]
80 public void IgnoredTest()
81 {
82 throw new Exception();
83 }
84 }
85}
Note: See TracBrowser for help on using the repository browser.