コード例 #1
0
        public void Encrypt_WithIncorrectArguments()
        {
            // Arrange
            AesEncryptor aes = new AesEncryptor();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => aes.EncryptMessage(null, "test"));
            Assert.Throws <ArgumentNullException>(() => aes.EncryptMessage("", "test"));
            Assert.Throws <ArgumentNullException>(() => aes.EncryptMessage("test", null));
            Assert.Throws <ArgumentNullException>(() => aes.EncryptMessage("test", ""));
        }
コード例 #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);
        }