[1146] | 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 |
|
---|
| 7 | Option Explicit On
|
---|
| 8 | Imports System
|
---|
| 9 | Imports NUnit.Framework
|
---|
| 10 |
|
---|
| 11 | Namespace NUnit.Samples
|
---|
| 12 |
|
---|
| 13 | <TestFixture()> Public Class SimpleVBTest
|
---|
| 14 |
|
---|
| 15 | Private fValue1 As Integer
|
---|
| 16 | Private fValue2 As Integer
|
---|
| 17 |
|
---|
| 18 | Public Sub New()
|
---|
| 19 | MyBase.New()
|
---|
| 20 | End Sub
|
---|
| 21 |
|
---|
| 22 | <SetUp()> Public Sub Init()
|
---|
| 23 | fValue1 = 2
|
---|
| 24 | fValue2 = 3
|
---|
| 25 | End Sub
|
---|
| 26 |
|
---|
| 27 | <Test()> Public Sub Add()
|
---|
| 28 | Dim result As Double
|
---|
| 29 |
|
---|
| 30 | result = fValue1 + fValue2
|
---|
| 31 | Assert.AreEqual(6, result)
|
---|
| 32 | End Sub
|
---|
| 33 |
|
---|
| 34 | <Test()> Public Sub DivideByZero()
|
---|
| 35 | Dim zero As Integer
|
---|
| 36 | Dim result As Integer
|
---|
| 37 |
|
---|
| 38 | zero = 0
|
---|
| 39 | result = 8 / zero
|
---|
| 40 | End Sub
|
---|
| 41 |
|
---|
| 42 | <Test()> Public Sub TestEquals()
|
---|
| 43 | Assert.AreEqual(12, 12)
|
---|
| 44 | Assert.AreEqual(CLng(12), CLng(12))
|
---|
| 45 |
|
---|
| 46 | Assert.AreEqual(12, 13, "Size")
|
---|
| 47 | Assert.AreEqual(12, 11.99, 0, "Capacity")
|
---|
| 48 | End Sub
|
---|
| 49 |
|
---|
| 50 | <Test(), ExpectedException(GetType(Exception))> Public Sub ExpectAnException()
|
---|
| 51 | Throw New InvalidCastException()
|
---|
| 52 | End Sub
|
---|
| 53 |
|
---|
| 54 | <Test(), Ignore("sample ignore")> Public Sub IgnoredTest()
|
---|
| 55 | ' does not matter what we type the test is not run
|
---|
| 56 | Throw New ArgumentException()
|
---|
| 57 | End Sub
|
---|
| 58 |
|
---|
| 59 | End Class
|
---|
| 60 | End Namespace
|
---|