Esempio n. 1
0
        public void Decodes(string input, string expected)
        {
            var encoder = new CaesarEncoder(-2);

            var encoded = encoder.Encode(input);

            Assert.Equal(expected, encoded);
        }
Esempio n. 2
0
        public void EncodesAndDecodesToSameString(string input, int shift)
        {
            var encoder = new CaesarEncoder(shift);

            var encoded = encoder.Encode(input);
            var decoded = encoder.Decode(encoded);

            Assert.Equal(input, decoded);
        }
Esempio n. 3
0
        public void DecodedStringIsTheSame([Random(100)] int key)
        {
            var message = RandomMessage;

            var encoded = encoder.Encode(message, key);
            var decoded = encoder.Decode(encoded, key);

            Assert.AreEqual(message, decoded);
        }
Esempio n. 4
0
        public void DecodedStringIsTheSame([Random(100)] int key)
        {
            // Arrange
            var encoder = new CaesarEncoder();
            var random  = new Randomizer();
            var message = random.GetString();

            // Act
            var encoded = encoder.Encode(message, key);
            var decoded = encoder.Decode(encoded, key);

            // Assert
            Assert.AreEqual(message, decoded);
        }
Esempio n. 5
0
        public void Should_Encode_And_Decode_String()
        {
            // Arrange
            var ce      = new CaesarEncoder(1234);
            var message = "encrypt_and_decrypt";

            // Act
            var encodedMessage = ce.Encode(message);
            var decodedMessage = ce.Decode(encodedMessage);

            // Assert
            Assert.True(string.Equals(decodedMessage, message),
                        $"Expected: {message}; Actual: {decodedMessage}");
        }
Esempio n. 6
0
        public void Should_Encode_String()
        {
            // Arrange
            var ce       = new CaesarEncoder(1234);
            var message  = "test_string";
            var expected = "RjdFRjFFRkQ7QDk=";


            // Act
            var encodedMessage = ce.Encode(message);

            // Assert
            Assert.True(string.Equals(encodedMessage, expected),
                        $"Expected: {expected}; Actual: {encodedMessage}");
        }