public void GetBytes_ExceptionTest() { PBKDF2 kdf = new PBKDF2(1000, new HmacSha256()); byte[] pass = new byte[1]; byte[] salt = new byte[1]; Exception ex = Assert.Throws <ArgumentNullException>(() => kdf.GetBytes(null, salt, 32)); Assert.Contains("Password can not be null.", ex.Message); ex = Assert.Throws <ArgumentNullException>(() => kdf.GetBytes(pass, null, 32)); Assert.Contains("Salt can not be null.", ex.Message); ex = Assert.Throws <ArgumentOutOfRangeException>(() => kdf.GetBytes(pass, salt, -1)); Assert.Contains("Derived key length must be bigger than zero.", ex.Message); kdf.Dispose(); ex = Assert.Throws <ObjectDisposedException>(() => kdf.GetBytes(pass, salt, 10)); Assert.Contains("Instance was disposed.", ex.Message); }