示例#1
0
        public void Decodes(string input, string expected)
        {
            var encoder = new CaesarEncoder(-2);

            var encoded = encoder.Encode(input);

            Assert.Equal(expected, encoded);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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}");
        }
示例#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}");
        }