Exemplo n.º 1
0
        public void WordFinderServiceFindTest()
        {
            var matrix     = new string[] { "abcdc", "fgwio", "chill", "pqnsd", "uvdxy" };
            var wordstream = new string[] { "chill", "cold", "wind", "cloud" };

            var wordFinderService = new WordFinderService(matrix);
            var result            = wordFinderService.Find(wordstream);

            Assert.Equal(result, new List <string>()
            {
                "chill", "cold", "wind"
            });
        }
Exemplo n.º 2
0
        public void WordFinderServiceFindTestErrorFormat()
        {
            var matrix     = new string[] { "abcdcdefg", "fgwio", "chill", "pqnsd", "uvdxy" };
            var wordstream = new string[] { "chill", "cold", "wind", "cloud" };

            try
            {
                var wordFinderService = new WordFinderService(matrix);
                var result            = wordFinderService.Find(wordstream);
            }
            catch (Exception e)
            {
                Assert.Equal("Bad formatted matrix", e.Message);
            }
        }
Exemplo n.º 3
0
        public void WordFinderServiceFindTestErrorMaxSize()
        {
            var matrix     = new string[] { "abcdcefgh", "fgwiosdfa", "chillaaaa", "pqnsdbbbb", "uvdxycccc", "abcdcefgi", "fgwiosdfb", "chillaaab", "pqnsdbbba" };
            var wordstream = new string[] { "chill", "cold", "wind", "cloud" };

            try
            {
                var wordFinderService = new WordFinderService(matrix);
                var result            = wordFinderService.Find(wordstream);
            }
            catch (Exception e)
            {
                Assert.Equal("Matrix max size is 64x64", e.Message);
            }
        }
Exemplo n.º 4
0
    public static void Main(string[] args)
    {
        var matrix = new string[] { "abcdc", "fgwio", "chill", "pqnsd", "uvdxy" };

        var wordstream = new string[] { "chill", "cold", "wind", "cloud" };

        if (args.Length > 0)
        {
            wordstream = args;
        }

        string search = string.Empty;

        Console.WriteLine("Matrix:");
        Console.WriteLine();
        foreach (var item in matrix)
        {
            Console.WriteLine(item);
        }

        Console.WriteLine();
        Console.Write("Search terms separated by comma: " + string.Join(",", wordstream));
        Console.WriteLine();

        try
        {
            IWordFinderService wordFinderService = new WordFinderService(matrix);
            var result = wordFinderService.Find(wordstream);
            Console.WriteLine();
            Console.Write("Search result: ");
            Console.Write(string.Join(",", result));
        }
        catch (Exception ex) {
            Console.WriteLine();
            Console.Write("Error: " + ex.Message);
        }

        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine("Press any key to close");
        Console.ReadKey();
    }