/usr/share/doc/nunit/examples/csharp/failures/CSharpTest.cs is in libnunit-doc 2.6.3+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | // ****************************************************************
// This is free software licensed under the NUnit license. You
// may obtain a copy of the license as well as information regarding
// copyright ownership at http://nunit.org
// ****************************************************************
namespace NUnit.Samples
{
using System;
using NUnit.Framework;
/// <summary>Some simple Tests.</summary>
///
[TestFixture]
public class SimpleCSharpTest
{
/// <summary>
///
/// </summary>
protected int fValue1;
/// <summary>
///
/// </summary>
protected int fValue2;
/// <summary>
///
/// </summary>
[SetUp] public void Init()
{
fValue1= 2;
fValue2= 3;
}
/// <summary>
///
/// </summary>
///
[Test] public void Add()
{
double result= fValue1 + fValue2;
// forced failure result == 5
Assert.AreEqual(6, result, "Expected Failure.");
}
/// <summary>
///
/// </summary>
///
[Test] public void DivideByZero()
{
int zero= 0;
int result= 8/zero;
}
/// <summary>
///
/// </summary>
///
[Test] public void Equals()
{
Assert.AreEqual(12, 12, "Integer");
Assert.AreEqual(12L, 12L, "Long");
Assert.AreEqual('a', 'a', "Char");
Assert.AreEqual((object)12, (object)12, "Integer Object Cast");
Assert.AreEqual(12, 13, "Expected Failure (Integer)");
Assert.AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double).");
}
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void ExpectAnException()
{
throw new InvalidCastException();
}
[Test]
[Ignore("ignored test")]
public void IgnoredTest()
{
throw new Exception();
}
}
}
|