public void EncodeDecode_Successful()
        {
            var result = RailFenceCipher.Decode(
                RailFenceCipher.Encode(TestMessage, MinAllowedRailCount), MinAllowedRailCount);

            Assert.AreEqual(TestMessage, result);
        }
    public void Decode_with_six_rails()
    {
        var msg      = "133714114238148966225439541018335470986172518171757571896261";
        var sut      = new RailFenceCipher(6);
        var expected = "112358132134558914423337761098715972584418167651094617711286";

        Assert.Equal(expected, sut.Decode(msg));
    }
    public void Decode_with_five_rails()
    {
        var msg      = "EIEXMSMESAORIWSCE";
        var sut      = new RailFenceCipher(5);
        var expected = "EXERCISMISAWESOME";

        Assert.Equal(expected, sut.Decode(msg));
    }
    public void Decode_with_three_rails()
    {
        var msg      = "TEITELHDVLSNHDTISEIIEA";
        var sut      = new RailFenceCipher(3);
        var expected = "THEDEVILISINTHEDETAILS";

        Assert.Equal(expected, sut.Decode(msg));
    }
Example #5
0
    public void Decode_with_six_rails()
    {
        var railFenceCipher = new RailFenceCipher(6);
        var actual          = railFenceCipher.Decode("133714114238148966225439541018335470986172518171757571896261");
        var expected        = "112358132134558914423337761098715972584418167651094617711286";

        Assert.That(actual, Is.EqualTo(expected));
    }
Example #6
0
    public void Decode_with_five_rails()
    {
        var railFenceCipher = new RailFenceCipher(5);
        var actual          = railFenceCipher.Decode("EIEXMSMESAORIWSCE");
        var expected        = "EXERCISMISAWESOME";

        Assert.That(actual, Is.EqualTo(expected));
    }
Example #7
0
    public void Decode_with_three_rails()
    {
        var railFenceCipher = new RailFenceCipher(3);
        var actual          = railFenceCipher.Decode("TEITELHDVLSNHDTISEIIEA");
        var expected        = "THEDEVILISINTHEDETAILS";

        Assert.That(actual, Is.EqualTo(expected));
    }
Example #8
0
        public void Decode_with_three_rails()
        {
            var sentence = "WECRLTEERDSOEEFEAOCAIVDEN";
            var rail     = new RailFenceCipher(3);
            var expected = "WEAREDISCOVEREDFLEEATONCE";

            Assert.AreEqual(expected, rail.Decode(sentence));
        }
Example #9
0
    public void Decode_with_three_rails_2()
    {
        var msg      = "WECRLTEERDSOEEFEAOCAIVDEN";
        var sut      = new RailFenceCipher(3);
        var expected = "WEAREDISCOVEREDFLEEATONCE";

        Assert.Equal(expected, sut.Decode(msg));
    }
Example #10
0
 public void DecodeSampleTests()
 {
     string[][] decodes =
     {
         new[] { "159246837",                 "123456789"                 },
         new[] { "WECRLTEERDSOEEFEAOCAIVDEN", "WEAREDISCOVEREDFLEEATONCE" }, // 3 rails
         new[] { "H !e,Wdloollr",             "Hello, World!"             }, // 4 rails
         new[] { "",                          ""                          } // 3 rails (even if...)
     };
     int[] rails = { 3, 3, 4, 3 };
     for (int i = 0; i < decodes.Length; i++)
     {
         Assert.AreEqual(decodes[i][1], RailFenceCipher.Decode(decodes[i][0], rails[i]));
     }
 }
Example #11
0
        public void Decode_Tests()
        {
            string[][] decodes =
            {
                new[] { "WECRLTEERDSOEEFEAOCAIVDEN", "WEAREDISCOVEREDFLEEATONCE" },
                new[] { "H !e,Wdloollr",             "Hello, World!"             },
                new[] { "",                          ""                          }
            };

            int[] rails = { 3, 4, 3 };

            for (int i = 0; i < decodes.Length; i++)
            {
                Assert.AreEqual(decodes[i][1], RailFenceCipher.Decode(decodes[i][0], rails[i]));
            }
        }
Example #12
0
 private string DecodeSI(int a, string code, string eMessage)
 {
     if (code == "F")
     {
         RailFenceCipher railFenceCipher = new RailFenceCipher();
         return(railFenceCipher.Decode(eMessage, a));
     }
     if (code == "S")
     {
         RailFenceCipher railFenceCipher = new RailFenceCipher();
         return(railFenceCipher.Decode(eMessage, a));
     }
     else if (code == "C")
     {
         CaesarVariation caesarVariation = new CaesarVariation();
         return(caesarVariation.Decode(eMessage, a));
     }
     else
     {
         return("Error");
     }
 }
Example #13
0
        public void PublisherIdentityPermission()
        {
            //string[][] encodes =
            //{
            //    new[] { "WEAREDISCOVEREDFLEEATONCE", "WEEEAALTRFOEDNDECIRESECVO" },
            //    new[] { "WADCEFACTLROIREESVEEOENED", "WEAREDISCOVEREDFLEEATONCE" }
            //};
            //int[] rails1 = { 10, 8 };
            //for (int i = 0; i < encodes.Length; i++)
            //{
            //    Assert.AreEqual(encodes[i][1], RailFenceCipher.Encode(encodes[i][0], rails1[i]));
            //}

            string[][] decodes =
            {
                new[] { "WEAREDISCOVEREDFLEEATONCE", "WADCEFACTLROIREESVEEOENED" },
            };
            int[] rails2 = { 8 };
            for (int i = 0; i < decodes.Length; i++)
            {
                Assert.AreEqual(decodes[i][1], RailFenceCipher.Decode(decodes[i][0], rails2[i]));
            }
        }
 public void DecodeMessage_WrongRailCount_ThrowException(int railCount)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => RailFenceCipher.Decode(TestMessage, railCount));
 }
        public void DecodeMessage_EmptyString_ReturnEmptyString()
        {
            var result = RailFenceCipher.Decode(string.Empty, MinAllowedRailCount);

            Assert.AreEqual(string.Empty, result);
        }
        public void DecodeMessage_Successful(string encodedMessage, int railCount, string originalMessage)
        {
            var result = RailFenceCipher.Decode(encodedMessage, railCount);

            Assert.AreEqual(originalMessage, result);
        }