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", "")); }
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); }
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); }