Beispiel #1
0
        public void Scenario9Case3()
        {
            CrozzleMap map;

            List <String[]> rows    = new List <String[]>();
            List <String[]> columns = new List <String[]>();

            List <String> lines = new StreamReader(@"..\..\..\..\Test Files\CrozzleRow3.txt").ReadToEnd().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (String line in lines)
            {
                var result = Regex.Split(line, string.Empty).ToList();
                result.RemoveAt(0);
                result.RemoveAt(result.Count - 1);
                rows.Add(result.Select(str => (str.Length == 0) ? " " : str).ToArray());
            }

            lines = new StreamReader(@"..\..\..\..\Test Files\CrozzleColumn3.txt").ReadToEnd().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            foreach (String line in lines)
            {
                var result = Regex.Split(line, string.Empty).ToList();
                result.RemoveAt(0);
                result.RemoveAt(result.Count - 1);
                columns.Add(result.Select(str => (str.Length == 0) ? " " : str).ToArray());
            }

            map = new CrozzleMap(rows, columns);
            if (map.GroupCount() != 4)
            {
                Assert.Fail();
            }
        }
        public void TestMethod7()
        {
            // Arrange.
            string myCrozzleFile  = @"C:\temp\Old Program and Old Files\Assessment Task 1 Files\Test1.czl";
            string myWordlistFile = @"C:\temp\Old Program and Old Files\Assessment Task 1 Files\Test1.seq";
            string myConfigFile   = @"C:\temp\Old Program and Old Files\Assessment Task 1 Files\Test1.cfg";
            string myConfigFile2  = @"C:\temp\Old Program and Old Files\Test Files\unitTest9\Test1 Configuration_groupCount2.cfg";
            string myConfigFile3  = @"C:\temp\Old Program and Old Files\Test Files\unitTest9\Test1 Configuration_groupCount4.cfg";
            string myCrozzleFile2 = @"C:\temp\Old Program and Old Files\Test Files\unitTest9\Test1 Crozzle_groupCount2.czl";
            string myCrozzleFile3 = @"C:\temp\Old Program and Old Files\Test Files\unitTest9\Test1 Crozzle_groupCount4.czl";
            //test 1 - Original files
            Configuration config;

            Configuration.TryParse(myConfigFile, out config);
            WordList wordlist;

            WordList.TryParse(myWordlistFile, config, out wordlist);
            Crozzle crozzle;

            Crozzle.TryParse(myCrozzleFile, config, wordlist, out crozzle);
            CrozzleMap crozzleMap = new CrozzleMap(crozzle.CrozzleRows, crozzle.CrozzleColumns);

            //Test 2 - Files edited into two groups of connected words. Words removed are Mark and Jack
            Configuration config2;

            Configuration.TryParse(myConfigFile2, out config2);
            WordList wordlist2;

            WordList.TryParse(myWordlistFile, config2, out wordlist2);
            Crozzle crozzle2;

            Crozzle.TryParse(myCrozzleFile2, config2, wordlist2, out crozzle2);
            CrozzleMap crozzleMap2 = new CrozzleMap(crozzle2.CrozzleRows, crozzle2.CrozzleColumns);

            //test 3 - Files edited into four groups.
            Configuration config3;

            Configuration.TryParse(myConfigFile3, out config3);
            WordList wordlist3;

            WordList.TryParse(myWordlistFile, config3, out wordlist3);
            Crozzle crozzle3;

            Crozzle.TryParse(myCrozzleFile3, config3, wordlist3, out crozzle3);
            CrozzleMap crozzleMap3 = new CrozzleMap(crozzle3.CrozzleRows, crozzle3.CrozzleColumns);

            int expectedGroupCount     = 1;
            int expectedNewGroupCount1 = 2;
            int expectedNewGroupCount2 = 4;

            // Act.
            int ActualGroupCount     = crozzleMap.GroupCount();
            int ActualNewGroupCount1 = crozzleMap2.GroupCount();
            int ActualNewGroupCount2 = crozzleMap3.GroupCount();

            // Assert.
            Assert.AreEqual(expectedGroupCount, ActualGroupCount, "failed ...");
            Assert.AreEqual(expectedNewGroupCount1, ActualNewGroupCount1, "failed ...");
            Assert.AreEqual(expectedNewGroupCount2, ActualNewGroupCount2, "failed ...");
        }
        public void Test_CrozzleMap_GroupCount()
        {
            // Arrange
            setAttributes();
            int Test1 = 1;
            int Test2 = 4;
            int Test3 = 7;

            // Act
            CrozzleMap map1 = new CrozzleMap(aCrozzle1.getCrozzleRows(), aCrozzle1.getCrozzleColumns());
            CrozzleMap map2 = new CrozzleMap(aCrozzle2.getCrozzleRows(), aCrozzle2.getCrozzleColumns());
            CrozzleMap map3 = new CrozzleMap(aCrozzle3.getCrozzleRows(), aCrozzle3.getCrozzleColumns());

            // Assert
            Assert.AreEqual(Test1, map1.GroupCount(), "Error");
            Assert.AreEqual(Test2, map2.GroupCount(), "Error");
            Assert.AreEqual(Test3, map3.GroupCount(), "Error");
        }