Sha256: 1fd9d2d3a6099e7c4c6aeac884de9114a53eccb273e455eab70d692fcb151d34

Contents?: true

Size: 1.78 KB

Versions: 396

Compression:

Stored size: 1.78 KB

Contents

Imports NUnit.Framework

<TestFixture>
Public Class AccumulateTest
    <Test>
    Public Sub EmptyAccumulationProducesEmptyAccumulation()
        Assert.That(New Integer() {}.Accumulate(Function(x) x * x), [Is].EqualTo(New Integer() {}))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateSquares()
        Assert.That({1, 2, 3}.Accumulate(Function(x) x * x), [Is].EqualTo({1, 4, 9}))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateUpcases()
        Assert.That(New List(Of String)() From {
            "hello",
            "world"
        }.Accumulate(Function(x) x.ToUpper()), [Is].EqualTo(New List(Of String) From {
            "HELLO",
            "WORLD"
        }))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateReversedStrings()
        Assert.That("the quick brown fox etc".Split(" "c).Accumulate(AddressOf Reverse), [Is].EqualTo("eht kciuq nworb xof cte".Split(" "c)))
    End Sub

    Private Shared Function Reverse(value As String) As String
        Dim chars = value.ToCharArray()
        Array.Reverse(chars)
        Return New String(chars)
    End Function

    <Ignore>
    <Test>
    Public Sub AccumulateWithinAccumulate()
        Dim actual = New String() {"a", "b", "c"}.Accumulate(Function(c) String.Join(" ", New String() {"1", "2", "3"}.Accumulate(Function(d) c & d)))
        Assert.That(actual, [Is].EqualTo(New String() {"a1 a2 a3", "b1 b2 b3", "c1 c2 c3"}))
    End Sub

    <Ignore>
    <Test>
    Public Sub AccumulateIsLazy()
        Dim counter = 0
        Dim accumulation = New Integer() {1, 2, 3}.Accumulate(Function(x) x * System.Math.Max(System.Threading.Interlocked.Increment(counter), counter - 1))

        Assert.That(counter, [Is].EqualTo(0))
        accumulation.ToList()
        Assert.That(counter, [Is].EqualTo(3))
    End Sub
End Class

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.138 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.137 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.136 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.135 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.134 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.133 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.132 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.131 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.130 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.129 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.128 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.127 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.126 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.125 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.124 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.123 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.122 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.121 tracks/vbnet/exercises/accumulate/AccumulateTest.vb
trackler-2.2.1.120 tracks/vbnet/exercises/accumulate/AccumulateTest.vb