public void TestMethod_Buble_Sort_random_element_list()
        {
            List <int> source   = new List <int>();
            List <int> expected = new List <int>();

            //could be for (int i = 0; i < 10000000; i++) //but way too long
            for (int i = 0; i < 10000; i++)
            {
                source.Add(CryptoFunc.GenerateRndNumberUsingCrypto(1, 254));
                expected.Add(CryptoFunc.GenerateRndNumberUsingCrypto(1, 254));
            }

            List <int> result    = SortFunc.BubbleSort(source);
            bool       isTheSame = true;

            for (int i = 0; i < result.Count; i++)
            {
                if (expected[i] != result[i])
                {
                    isTheSame = false;
                    break;
                }
            }

            Assert.IsFalse(isTheSame);
        }
Ejemplo n.º 2
0
        public void TestMethod_GenerateGreatRndNumberUsingCrypto_verify_all_numbers_are_generated()
        {
            int result  = CryptoFunc.GenerateGreatRndNumberUsingCrypto(1, 255);
            var dico    = new Dictionary <int, int>();
            var dicoRef = new Dictionary <int, bool>();

            for (int i = 1; i < 255; i++)
            {
                dicoRef.Add(i, false);
            }

            for (int i = 1; i < 1000; i++)
            {
                result = CryptoFunc.GenerateGreatRndNumberUsingCrypto(1, 254);
                if (dico.ContainsKey(result))
                {
                    dico[result]++;
                }
                else
                {
                    dico.Add(result, 1);
                }

                dicoRef[result] = true;
            }

            Assert.IsTrue(dicoRef.ContainsValue(false));
            //Assert.IsTrue(HaveAllValues(dico)); //bug
        }
Ejemplo n.º 3
0
        public void TestMethod_RsaDecryption_source_is_a_the_same_after_encryption_and_decryption()
        {
            const string source = "A long long time ago in a galaxy far far away";
            string       result = CryptoFunc.RsaDecryption(CryptoFunc.RsaEncryption(source));

            Assert.AreEqual(result, source);
        }
Ejemplo n.º 4
0
        public void TestMethod_RsaEncryption_encryption_not_null()
        {
            const string source = "A long long time ago in a galaxy far far away";
            string       result = CryptoFunc.RsaEncryption(source);

            Assert.IsNotNull(result);
        }
Ejemplo n.º 5
0
        public void TestMethod_RsaEncryption_source_and_encryption_are_different()
        {
            const string source = "A long long time ago in a galaxy far far away";
            string       result = CryptoFunc.RsaEncryption(source);

            Assert.AreNotEqual(result, source);
        }
Ejemplo n.º 6
0
        public void TestMethod_RsaEncryption_encryption_not_empty()
        {
            const string source = "A long long time ago in a galaxy far far away";
            string       result = CryptoFunc.RsaEncryption(source);

            Assert.IsTrue(result.Length != 0);
            Assert.AreNotEqual(result.Length, 0);
        }
Ejemplo n.º 7
0
        public void TestMethod_RsaEncryption_one_letter()
        {
            const string source   = "a";
            const string expected = "Pk+xT6QpGq0h4hdYdIlLZr2Cg1wOZ3v6qQXkIvqmwwdXPd1MdhoICk4N4jHXqGBfFJzIN/cbeHbVaiEbEIuCe5tEvaS5AFVrF3PATmCVWHtRBJsR5tvihQOxecd52AHRjpZhbX9sawpHpxQ5iKOpyT6gQ6icG+oSaYcwx8xn7ag=";
            string       result   = CryptoFunc.RsaEncryption(source);

            Assert.AreNotEqual(result, expected);
        }
Ejemplo n.º 8
0
        public void TestMethod_GenerateGreatRndNumberUsingCrypto_has_255_at_least_once()
        {
            int result = CryptoFunc.GenerateGreatRndNumberUsingCrypto(1, 255);

            for (int i = 2; i < 100; i++)
            {
                result = CryptoFunc.GenerateGreatRndNumberUsingCrypto(1, i);
                if (result == 255)
                {
                    Assert.IsTrue(result == 255);
                }
            }
        }
Ejemplo n.º 9
0
        public void TestMethod_GenerateRndNumberUsingCrypto_lesser_than_254()
        {
            int result = CryptoFunc.GenerateRndNumberUsingCrypto(1, 254);

            Assert.IsTrue(result <= 254);
        }
Ejemplo n.º 10
0
        public void TestMethod_GenerateRndNumberUsingCrypto_greater_than_1()
        {
            int result = CryptoFunc.GenerateRndNumberUsingCrypto(1, 254);

            Assert.IsTrue(result >= 1);
        }
Ejemplo n.º 11
0
        public void TestMethod_GenerateGreatRndNumberUsingCrypto_has_255()
        {
            int result = CryptoFunc.GenerateGreatRndNumberUsingCrypto(255, 255);

            Assert.IsTrue(result == 255);
        }
Ejemplo n.º 12
0
        public void TestMethod_GenerateGreatRndNumberUsingCrypto_min_equal_max()
        {
            int result = CryptoFunc.GenerateGreatRndNumberUsingCrypto(10, 10);

            Assert.IsTrue(result == 10);
        }