Example #1
0
    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>();
    }
Example #2
0
    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>();
    }
Example #3
0
    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>();
    }
Example #4
0
    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);
    }
Example #5
0
    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);
    }