public void EncryptTest(PrivateKey key, string pass, string expectedComp, string expectedUncomp) { using BIP0038 bip = new BIP0038(); string actualComp = bip.Encrypt(key, pass, true); string actualUncomp = bip.Encrypt(key, pass, false); Assert.Equal(expectedComp, actualComp); Assert.Equal(expectedUncomp, actualUncomp); }
public void Encrypt_String_ExceptionTest() { BIP0038 bip = new BIP0038(); PrivateKey k = KeyHelper.Prv1; string nstr = null; Exception ex = Assert.Throws <ArgumentNullException>(() => bip.Encrypt(null, "a", true)); Assert.Contains("Private key can not be null.", ex.Message); ex = Assert.Throws <ArgumentNullException>(() => bip.Encrypt(k, nstr, true)); Assert.Contains("Password can not be null or empty.", ex.Message); ex = Assert.Throws <ArgumentNullException>(() => bip.Encrypt(k, "", true)); Assert.Contains("Password can not be null or empty.", ex.Message); bip.Dispose(); ex = Assert.Throws <ObjectDisposedException>(() => bip.Encrypt(k, "a", true)); Assert.Contains("Instance was disposed.", ex.Message); }