Пример #1
0
        public void TestHash()
        {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";

            var rand = new Random();

            var hashTests = new ITestConfiguration[5];

            for (uint i = 0; i < hashTests.Length - 1; i++)
            {
                int numValues = rand.Next(10, 20);
                var values    = new string[numValues];

                for (int v = 0; v < numValues; v++)
                {
                    if (rand.NextDouble() < 0.5)
                    {
                        // generate string of numbers only
                        values[v] = rand.Next(1000000).ToString("000000");
                    }
                    else
                    {
                        // generate random string
                        int length = rand.Next(10, 20); // random length (in characters)

                        values[v] = new string(Enumerable
                                               .Repeat(chars, length)
                                               .Select(s => s[rand.Next(s.Length)])
                                               .ToArray());
                    }
                }

                hashTests[i] = new HashTestConfiguration
                {
                    Values = values.ToList()
                };
            }

            hashTests[hashTests.Length - 1] = new HashTestConfiguration
            {
                Values = new[] { "是是asda阿斯顿", " ", "     ", "\t\r\n", "\r", "hô ooaf à ị ẻ ể \r \t \n \\ồ" }.ToList()
            };

            Run(outputFilePatternExpected, outputFilePatternActual, outputJsonConfigFile, hashTests);

            for (uint i = 0; i < hashTests.Length; i++)
            {
                // integer content so should be exact match
                CompareExactMatch(FormatPath(outputFilePatternExpected, i), FormatPath(outputFilePatternActual, i));
            }
        }
Пример #2
0
        public void TestHash()
        {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";

            var rand = new Random();

            var hashTests = new ITestConfiguration[5];
            for (uint i = 0; i < hashTests.Length - 1; i++)
            {
                int numValues = rand.Next(10, 20);
                var values = new string[numValues];

                for (int v = 0; v < numValues; v++)
                {
                    if (rand.NextDouble() < 0.5)
                    {
                        // generate string of numbers only
                        values[v] = rand.Next(1000000).ToString("000000");
                    }
                    else
                    {
                        // generate random string
                        int length = rand.Next(10, 20); // random length (in characters)

                        values[v] = new string(Enumerable
                            .Repeat(chars, length)
                            .Select(s => s[rand.Next(s.Length)])
                            .ToArray());
                    }
                }

                hashTests[i] = new HashTestConfiguration
                {
                    Values = values.ToList()
                };
            }

            hashTests[hashTests.Length - 1] = new HashTestConfiguration
            {
                Values = new[] { "是是asda阿斯顿", " ", "     ", "\t\r\n", "\r", "hô ooaf à ị ẻ ể \r \t \n \\ồ" }.ToList()
            };

            Run(outputFilePatternExpected, outputFilePatternActual, outputJsonConfigFile, hashTests);

            for (uint i = 0; i < hashTests.Length; i++)
            {
                // integer content so should be exact match
                CompareExactMatch(FormatPath(outputFilePatternExpected, i), FormatPath(outputFilePatternActual, i));
            }
        }