public void No_EncryptedContents_Returns_None_With_UnlockWhenEncryptedContentsIsNullMsg() { // Arrange var box = new Locked <int>(); var key = CryptoF.GenerateKey().UnsafeUnwrap(); // Act var result = box.Unlock(key); // Assert result.AssertNone().AssertType <UnlockWhenEncryptedContentsIsNoneMsg>(); }
public void Invalid_Key_Returns_None_With_InvalidKeyExceptionMsg() { // Arrange var value = Rnd.Str; var key = CryptoF.GenerateKey().UnsafeUnwrap(); var box = new Locked <string>(value, key); // Act var result = box.Unlock(Rnd.ByteF.Get(16)); // Assert result.AssertNone().AssertType <InvalidKeyExceptionMsg>(); }
public void Incorrect_Key_Returns_None_With_IncorrectKeyOrNonceMsg() { // Arrange var value = Rnd.Str; var key = CryptoF.GenerateKey().UnsafeUnwrap(); var incorrectKey = CryptoF.GenerateKey().UnsafeUnwrap(); var box = new Locked <string>(value, key); // Act var result = box.Unlock(incorrectKey); // Assert result.AssertNone().AssertType <IncorrectKeyOrNonceExceptionMsg>(); }
public void Byte_Key_Returns_Lockable() { // Arrange var value = Rnd.Str; var key = CryptoF.GenerateKey().UnsafeUnwrap(); var box = new Locked <string>(value, key); // Act var result = box.Unlock(key); // Assert var some = result.AssertSome(); Assert.Equal(value, some.Contents); }
public void String_Key_Returns_Lockable() { // Arrange var value = Rnd.Str; var key = Rnd.Str; var box = new Locked <string>(value, key); // Act var result = box.Unlock(key); // Assert var some = result.AssertSome(); Assert.Equal(value, some.Contents); }