Ejemplo n.º 1
0
        public void TestGetBinPower()
        {
            long n = (long)Math.Pow(2, 50);
            long m = BinAuth.GetBinPower(50);

            m.Should().Be(n);
        }
Ejemplo n.º 2
0
 public void TestIsBinPower()
 {
     for (int i = 0; i < 64; i++)
     {
         long n = BinAuth.GetBinPower(i);
         BinAuth.IsBinPower(n).Should().BeTrue();
     }
 }
Ejemplo n.º 3
0
        public void TestRemoveAuth()
        {
            long authCode = 9223372036854775806;//表示最大权限值

            for (int i = 1; i <= 62; i++)
            {
                long x = BinAuth.GetBinPower(i);
                authCode = BinAuth.RemoveAuth(authCode, x);
            }
            Assert.Equal(0L, authCode);
        }
Ejemplo n.º 4
0
        public void TestAddAuth()
        {
            long authCode = 0;

            for (int i = 1; i <= 62; i++)
            {
                long x = BinAuth.GetBinPower(i);
                authCode = BinAuth.AddAuth(authCode, x);
            }
            Assert.Equal(9223372036854775806, authCode);
        }
Ejemplo n.º 5
0
        public void TestGenAuthCode()
        {
            long        authCode = 0;
            List <long> codeList = new List <long>();

            for (int i = 1; i <= 62; i++)
            {
                codeList.Add((long)Math.Pow(2, i));
            }
            authCode = BinAuth.GenAuthCode(codeList.ToArray());
            Assert.Equal(9223372036854775806, authCode);
        }
Ejemplo n.º 6
0
        public void TestIsHasAuth()
        {
            long authCode = 0;

            for (int i = 1; i <= 62; i++)
            {
                long x = BinAuth.GetBinPower(i);
                authCode = BinAuth.AddAuth(authCode, x);
                BinAuth.IsHasAuth(authCode, x).Should().BeTrue();
            }

            for (int i = 1; i <= 62; i++)
            {
                BinAuth.IsHasAuth(authCode, BinAuth.GetBinPower(i)).Should().BeTrue();
            }

            BinAuth.IsHasAuth(-1, 0).Should().BeFalse();
            BinAuth.IsHasAuth(0, 0).Should().BeFalse();
        }