' Collection of code snippets by Arne Vajhøj 
' (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
Imports NUnit.Framework

<TestFixture()> _
Public Class MathVectorTest

    <SetUp()> _
    Protected Sub Init()
    End Sub

    <TearDown()> _
    Protected Sub Dispose()
    End Sub

    <Test()> _
    Public Sub OpAdd()
        Dim v As Integer() =  {-1000000, -1, 0, 1, 1000000}
        Dim mv As MathVector = New MathVector(v)
        Dim mv2 As MathVector = mv.OpAdd(777)
        Assert.AreEqual(mv.Count, mv2.Count, "OpAdd Count")
        Dim i As Integer
        For i = 0 To (mv2.Count - 1)
            Assert.AreEqual(mv.V(i) + 777, mv2.V(i), "OpAdd " & i)
        Next
    End Sub

    <Test()> _
    Public Sub OpSub()
        Dim v As Integer() =  {-1000000, -1, 0, 1, 1000000}
        Dim mv As MathVector = New MathVector(v)
        Dim mv2 As MathVector = mv.OpSub(777)
        Assert.AreEqual(mv.Count, mv2.Count, "OpSub Count")
        Dim i As Integer
        For i = 0 To (mv2.Count - 1)
            Assert.AreEqual(mv.V(i) - 777, mv2.V(i), "OpSub " & i)
        Next
    End Sub

    <Test()> _
    Public Sub OpMul()
        Dim v As Integer() =  {-1000000, -1, 0, 1, 1000000}
        Dim mv As MathVector = New MathVector(v)
        Dim mv2 As MathVector = mv.OpMul(777)
        Assert.AreEqual(mv.Count, mv2.Count, "OpMul Count")
        Dim i As Integer
        For i = 0 To (mv2.Count - 1)
            Assert.AreEqual(mv.V(i) * 777, mv2.V(i), "OpMul " & i)
        Next
    End Sub

    <Test()> _
    Public Sub OpDiv()
        Dim v As Integer() =  {-1000000, -1, 0, 1, 1000000}
        Dim mv As MathVector = New MathVector(v)
        Dim mv2 As MathVector = mv.OpDiv(777)
        Assert.AreEqual(mv.Count, mv2.Count, "OpDiv Count")
        Dim i As Integer
        For i = 0 To (mv2.Count - 1)
            Assert.AreEqual(mv.V(i) \ 777, mv2.V(i), "OpDiv " & i)
        Next
    End Sub

    <Test()> _
    Public Sub OpMod()
        Dim v As Integer() =  {-1000000, -1, 0, 1, 1000000}
        Dim mv As MathVector = New MathVector(v)
        Dim mv2 As MathVector = mv.OpMod(777)
        Assert.AreEqual(mv.Count, mv2.Count, "OpMod Count")
        Dim i As Integer
        For i = 0 To (mv2.Count - 1)
            Assert.AreEqual(mv.V(i) Mod 777, mv2.V(i), "OpMod " & i)
        Next
    End Sub
End Class 

