예제 #1
0
        public void Scenario6Case3()
        {
            CrozzleSequences crozzleSequences;
            Int32            lowerLimit, upperLimit;

            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());
            }

            lowerLimit = 0;
            upperLimit = 0;

            crozzleSequences = new CrozzleSequences(rows, columns, new Configuration(@"..\..\..\..\Test Files\UnitTest1.cfg"));

            crozzleSequences.CheckDuplicateWords(lowerLimit, upperLimit);
            Assert.IsTrue(crozzleSequences.ErrorMessages.Count == 3);
        }
        public void Test_CrozzleSequences_CheckDuplicateWords()
        {
            // Arrange
            setAttributes();
            CrozzleSequences aCrozzle1Sequences = new CrozzleSequences(aCrozzle1.getCrozzleRows(), aCrozzle1.getCrozzleColumns(), aCrozzle1.Configuration);
            CrozzleSequences aCrozzle2Sequences = new CrozzleSequences(aCrozzle2.getCrozzleRows(), aCrozzle2.getCrozzleColumns(), aCrozzle2.Configuration);
            CrozzleSequences aCrozzle3Sequences = new CrozzleSequences(aCrozzle3.getCrozzleRows(), aCrozzle3.getCrozzleColumns(), aCrozzle3.Configuration);

            // Act
            aCrozzle1Sequences.CheckDuplicateWords(aCrozzle1.Configuration.MinimumNumberOfTheSameWord, aCrozzle1.Configuration.MaximumNumberOfTheSameWord);
            aCrozzle2Sequences.CheckDuplicateWords(aCrozzle2.Configuration.MinimumNumberOfTheSameWord, aCrozzle2.Configuration.MaximumNumberOfTheSameWord);
            aCrozzle3Sequences.CheckDuplicateWords(aCrozzle3.Configuration.MinimumNumberOfTheSameWord, aCrozzle3.Configuration.MaximumNumberOfTheSameWord);

            // Assert
            Assert.AreEqual(0, aCrozzle1Sequences.DuplicateWordsCount, "error");
            Assert.AreEqual(3, aCrozzle2Sequences.DuplicateWordsCount, "error");
            Assert.AreEqual(0, aCrozzle3Sequences.DuplicateWordsCount, "error");
        }
예제 #3
0
        public void TestMethod6()
        {
            // Arrange.
            string        myCrozzleFile  = @"C:\SIT323_Assignment1\Old Program and Old Files\Test 1 Crozzle.txt";
            string        myWordlistFile = @"C:\SIT323_Assignment1\Old Program and Old Files\Test 1 Wordlist.txt";
            string        myConfigFile   = @"C:\SIT323_Assignment1\Old Program and Old Files\Test 1 Configuration.txt";
            Configuration config;

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

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

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

            //SECOND FILES - Files changed so that there are two "RON" with valid config file max duplcates capped a 2.
            string        myCrozzleFile2  = @"C:\SIT323_Assignment1\Old Program and Old Files\unitTest6\Test 1 Crozzle_checkDuplicates.txt";
            string        myWordlistFile2 = @"C:\SIT323_Assignment1\Old Program and Old Files\unitTest6\Test 1 Wordlist_checkDuplicates.txt";
            string        myConfigFile2   = @"C:\SIT323_Assignment1\Old Program and Old Files\unitTest6\Test 1 Configuration_checkDuplicates.txt";
            Configuration config2;

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

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

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

            //Third Test - Files changed so that there are two "RON" but with config max duplicates capped at 1.
            string        myCrozzleFile3  = @"C:\SIT323_Assignment1\Old Program and Old Files\unitTest6\Test 1 Crozzle_checkDuplicates.txt";
            string        myWordlistFile3 = @"C:\SIT323_Assignment1\Old Program and Old Files\unitTest6\Test 1 Wordlist_checkDuplicates.txt";
            string        myConfigFile3   = @"C:\SIT323_Assignment1\Old Program and Old Files\Test 1 Configuration.txt";
            Configuration config3;

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

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

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


            bool expectedFalseErrors    = false;
            bool expectedFalseErrorsNew = false;
            bool expectedTrueErrorsNew  = true;

            // Act.
            crozzleSequences.CheckDuplicateWords(1, 1);
            crozzleSequences2.CheckDuplicateWords(1, 2);
            crozzleSequences3.CheckDuplicateWords(1, 1);
            bool actualFalseErrors    = crozzleSequences.ErrorsDetected;
            bool actualFalseErrorsNew = crozzleSequences2.ErrorsDetected;
            bool actualTrueErrorsNew  = crozzleSequences3.ErrorsDetected;

            // Assert.
            Assert.AreEqual(expectedFalseErrors, actualFalseErrors, "failed ...");
            Assert.AreEqual(expectedFalseErrorsNew, actualFalseErrorsNew, "failed ...");
            Assert.AreEqual(expectedTrueErrorsNew, actualTrueErrorsNew, "failed ...");
        }