示例#1
0
        public void Decrypt_WithIncorrectArguments()
        {
            // Arrange
            AesEncryptor aes = new AesEncryptor();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => aes.DecryptMessage(null, "test"));
            Assert.Throws <ArgumentNullException>(() => aes.DecryptMessage(new Message(), "test"));
            Assert.Throws <ArgumentNullException>(() => aes.DecryptMessage(new Message {
                Value = new byte[5]
            }, null));
            Assert.Throws <ArgumentNullException>(() => aes.DecryptMessage(new Message {
                Value = new byte[5]
            }, ""));
        }
示例#2
0
        public void Decrypt_WithIncorrectKey()
        {
            // Arrange
            AesEncryptor aes   = new AesEncryptor();
            string       value = "Test message";
            string       key   = "Test Key";

            // Act
            Message message      = aes.EncryptMessage(value, key);
            string  decryptValue = aes.DecryptMessage(message, "incorrect key");

            // Assert
            Assert.Null(decryptValue);
        }
示例#3
0
        public void CheckEncryptionForSymetric()
        {
            // Arrange
            AesEncryptor aes   = new AesEncryptor();
            string       value = "Test message";
            string       key   = "Test Key";

            // Act
            Message message      = aes.EncryptMessage(value, key);
            string  decryptValue = aes.DecryptMessage(message, key);

            // Assert
            Assert.Equal(value, decryptValue);
        }