Example #1
0
        public void GenerateSuffixSearchTestCases(int count)
        {
            var vocabulary  = NonsenseGeneration.GetVocabulary();
            var words       = NonsenseGeneration.GetRandomNeighbourWordGroups(vocabulary, count).ToArray();
            var idsAndWords = new KeyValuePair <int, string> [words.Length];

            for (int i = 0; i < words.Length; i++)
            {
                idsAndWords[i] = new KeyValuePair <int, string>(i, words[i]);
            }

            using (var output = File.CreateText(string.Format("SuffixSearchTestCases{0}.txt", count)))
            {
                WriteArrayDeclaration(count.ToString(), words, output);

                foreach (var keyValuePair in idsAndWords)
                {
                    var word = keyValuePair.Value;
                    foreach (var query in GetAllSubstrings(word))
                    {
                        string query1 = query;
                        var    actual =
                            idsAndWords
                            .Where(idWordPair => idWordPair.Value.Contains(query1))
                            .Select(idWordPair => idWordPair.Key);

                        string array = string.Join(",", actual.Select(id => id.ToString()));
                        output.WriteLine("[TestCase(\"{0}\", new[] {{{1}}})]", query, array);
                    }
                }
            }
        }
Example #2
0
        public void GenerateParallelAddTestCases(int count)
        {
            var vocabulary = NonsenseGeneration.GetVocabulary();
            var phrases    = new string[40];
            var random     = new Random();

            for (int i = 0; i < count; i++)
            {
                var words = NonsenseGeneration.GetRandomWords(vocabulary, 30, random);
                phrases[i] = string.Join(string.Empty, words);
            }
            using (var output = File.CreateText(string.Format("ParallelAddTestCases{0}.txt", count)))
            {
                WriteArrayDeclaration(count.ToString(), phrases, output);
            }
        }