Exemplo n.º 1
0
 public void KeySizes()
 {
     var keySizes = new BCRYPT_KEY_LENGTHS_STRUCT
     {
         MinLength = 8,
         MaxLength = 12,
         Increment = 2,
     };
     Assert.Equal(new[] { 8, 10, 12 }, keySizes.KeySizes);
 }
    public void EnsureValidKeyLength_FailureCases(int minLength, int maxLength, int increment, int testValue)
    {
        // Arrange
        var keyLengthsStruct = new BCRYPT_KEY_LENGTHS_STRUCT
        {
            dwMinLength = (uint)minLength,
            dwMaxLength = (uint)maxLength,
            dwIncrement = (uint)increment
        };

        // Act & assert
        ExceptionAssert.ThrowsArgumentOutOfRange(
            () => keyLengthsStruct.EnsureValidKeyLength((uint)testValue),
            paramName: "keyLengthInBits",
            exceptionMessage: Resources.FormatBCRYPT_KEY_LENGTHS_STRUCT_InvalidKeyLength(testValue, minLength, maxLength, increment));
    }
    public void EnsureValidKeyLength_SuccessCases(int minLength, int maxLength, int increment, int testValue)
    {
        // Arrange
        var keyLengthsStruct = new BCRYPT_KEY_LENGTHS_STRUCT
        {
            dwMinLength = (uint)minLength,
            dwMaxLength = (uint)maxLength,
            dwIncrement = (uint)increment
        };

        // Act
        keyLengthsStruct.EnsureValidKeyLength((uint)testValue);

        // Assert
        // Nothing to do - if we got this far without throwing, success!
    }
Exemplo n.º 4
0
    public void KeySizes()
    {
        var keySizes = new BCRYPT_KEY_LENGTHS_STRUCT
        {
            MinLength = 8,
            MaxLength = 12,
            Increment = 2,
        };

        Assert.Equal(new[] { 8, 10, 12 }, keySizes);

        keySizes = new BCRYPT_KEY_LENGTHS_STRUCT
        {
            MinLength = 16,
            MaxLength = 16,
            Increment = 0,
        };
        Assert.Equal(new[] { 16 }, keySizes);
    }