public void TestEqualsFalseForDifferent()
        {
            var e1 = NumberLength.FromBitLength(10);
            var e2 = NumberLength.FromBitLength(12);

            Assert.AreNotEqual(e1, e2);
        }
        public void TestEqualsTrueForEqual()
        {
            var e1 = NumberLength.FromBitLength(10);
            var e2 = NumberLength.FromBitLength(10);

            Assert.AreEqual(e1, e2);
        }
        public void TestInBytes(int bl, int expected)
        {
            var l      = NumberLength.FromBitLength(bl);
            var result = l.InBytes;

            Assert.AreEqual(expected, result);
        }
Example #4
0
        public void TestOrderBitLengthCallsAlgebra()
        {
            int rawBitLength = 11;

            var algebraStub = new Mock <ICryptoGroupAlgebra <BigInteger, int> >(MockBehavior.Strict);

            algebraStub.Setup(alg => alg.OrderBitLength).Returns(rawBitLength);

            var group = new CryptoGroup <BigInteger, int>(algebraStub.Object);

            var result   = group.OrderLength;
            var expected = NumberLength.FromBitLength(algebraStub.Object.OrderBitLength);

            Assert.AreEqual(expected, result);
        }
Example #5
0
        public void TestElementBitLengthCallsAlgebra()
        {
            int expectedRaw = 11;

            var algebraMock = new Mock <ICryptoGroupAlgebra <BigInteger, int> >(MockBehavior.Strict);

            algebraMock.Setup(alg => alg.ElementBitLength).Returns(expectedRaw);

            var group = new CryptoGroup <BigInteger, int>(algebraMock.Object);

            var result   = group.ElementLength;
            var expected = NumberLength.FromBitLength(expectedRaw);

            Assert.AreEqual(expected, result);

            algebraMock.Verify(alg => alg.ElementBitLength, Times.Once());
        }
        public void TestFromBitLength(int bl)
        {
            var l = NumberLength.FromBitLength(bl);

            Assert.AreEqual(bl, l.InBits);
        }