1
exercism fetch vbnet crypto-square

CryptoSquareTest.vb

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
86
87
88
89
90
91
92
93
94
Imports NUnit.Framework

<TestFixture>
Public Class CryptoSquareTest
    <Test>
    Public Sub StrangeCharactersAreStrippedDuringNormalization()
        Dim crypto = New Crypto("s#$%^&plunk")
        Assert.That(crypto.NormalizePlaintext, [Is].EqualTo("splunk"))
    End Sub

    <Ignore>
    <Test>
    Public Sub LettersAreLowercasedDuringNormalization()
        Dim crypto = New Crypto("WHOA HEY!")
        Assert.That(crypto.NormalizePlaintext, [Is].EqualTo("whoahey"))
    End Sub

    <Ignore>
    <Test>
    Public Sub NumbersAreKeptDuringNormalization()
        Dim crypto = New Crypto("1, 2, 3, GO!")
        Assert.That(crypto.NormalizePlaintext, [Is].EqualTo("123go"))
    End Sub

    <Ignore>
    <Test>
    Public Sub SmallestSquareSizeIs2()
        Dim crypto = New Crypto("1234")
        Assert.That(crypto.Size, [Is].EqualTo(2))
    End Sub

    <Ignore>
    <Test>
    Public Sub SizeOfTextWhoseLengthIsAPerfectSquareIsItsSquareRoot()
        Dim crypto = New Crypto("123456789")
        Assert.That(crypto.Size, [Is].EqualTo(3))
    End Sub

    <Ignore>
    <Test>
    Public Sub SizeOfTextWhoseLengthIsNotAPerfectSquareIsNextBiggestSquareRoot()
        Dim crypto = New Crypto("123456789abc")
        Assert.That(crypto.Size, [Is].EqualTo(4))
    End Sub

    <Ignore>
    <Test>
    Public Sub SizeIsDeterminedByNormalizedText()
        Dim crypto = New Crypto("Oh hey, this is nuts!")
        Assert.That(crypto.Size, [Is].EqualTo(4))
    End Sub

    <Ignore>
    <Test>
    Public Sub SegmentsAreSplitBySquareSize()
        Dim crypto = New Crypto("Never vex thine heart with idle woes")
        Assert.That(crypto.PlaintextSegments(), [Is].EqualTo(New String() {"neverv", "exthin", "eheart", "withid", "lewoes"}))
    End Sub

    <Ignore>
    <Test>
    Public Sub SegmentsAreSplitBySquareSizeUntilTextRunsOut()
        Dim crypto = New Crypto("ZOMG! ZOMBIES!!!")
        Assert.That(crypto.PlaintextSegments(), [Is].EqualTo(New String() {"zomg", "zomb", "ies"}))
    End Sub

    <Ignore>
    <Test>
    Public Sub CiphertextCombinesTextByColumn()
        Dim crypto = New Crypto("First, solve the problem. Then, write the code.")
        Assert.That(crypto.Ciphertext(), [Is].EqualTo("foeewhilpmrervrticseohtottbeedshlnte"))
    End Sub

    <Ignore>
    <Test>
    Public Sub CiphertextSkipsCellsWithNoText()
        Dim crypto = New Crypto("Time is an illusion. Lunchtime doubly so.")
        Assert.That(crypto.Ciphertext(), [Is].EqualTo("tasneyinicdsmiohooelntuillibsuuml"))
    End Sub

    <Ignore>
    <Test>
    Public Sub NormalizedCiphertextIsSplitBy5()
        Dim crypto = New Crypto("Vampires are people too!")
        Assert.That(crypto.NormalizeCiphertext(), [Is].EqualTo("vrela epems etpao oirpo"))
    End Sub

    <Ignore>
    <Test>
    Public Sub NormalizedCiphertextNotExactlyDivisibleBy5SpillsIntoASmallerSegment()
        Dim crypto = New Crypto("Madness, and then illumination.")
        Assert.That(crypto.NormalizeCiphertext(), [Is].EqualTo("msemo aanin dninn dlaet ltshu i"))
    End Sub
End Class