public void RandomIntegerReturnsAnIntegerOfTheGivenSize() { var rnd = SrpInteger.RandomInteger(1); Assert.AreEqual(2, rnd.ToHex().Length); Assert.AreNotEqual("00", rnd.ToHex()); rnd = SrpInteger.RandomInteger(8); Assert.AreEqual(16, rnd.ToHex().Length); Assert.AreNotEqual("0000000000000000", rnd.ToHex()); }
public void InvalidValues() { // negative bytes Assert.Throws <ArgumentException>(() => SrpInteger.RandomInteger(0)); Assert.Throws <ArgumentException>(() => SrpInteger.RandomInteger(-1)); // hex length not specified var tmp = new SrpInteger("1234"); Assert.Throws <InvalidOperationException>(() => tmp.ToHex()); }