public void Verify_Target_Test2_ParsingTxtFile1()
        {
            /*
             *
             * //{Original Untrimmed Array}
             * XXXXXXXXX
             * XXXX1XXXX
             * XXX111XXX
             * XX11X11XX
             * XXXXXXXXX
             * XXXXXXXXX
             *
             */

            var expected = new char[, ]
            {
                { 'X', 'X', '1', 'X', 'X' },
                { 'X', '1', '1', '1', 'X' },
                { '1', '1', 'X', '1', '1' },
            };

            var target = new TargetImageTextFile("testfile1", @"OOPTests/TestFile2.txt", 'X');

            var actual = target.GridRepresentation;

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        private static void InitialiseTargetImages_TextFile()
        {
            //Get array of absolute filepaths for SnapperImages (although there should only be 1! We will throw an exception where this isnt the case
            //to ensure the user is not misled, instead of just taking the first one.)
            string[] targetImageFilePaths =
                DirectoryHelpers.GetFilesWithinDirectoryWithCertainFileExtension(targetsDirectoryPath, fileExtension);

            //Handle cases where there isn't exactly 1 .blf file and throw exception if this is the case.
            if (targetImageFilePaths.Length < 1 || targetImageFilePaths == null)
            {
                throw new InvalidProgramException("*ERROR* Invalid map data: directory must contain exactly 1 .blf file. ");
            }

            var targetImages = new List <ITargetImage>();

            foreach (string targetImageTextFilePath in targetImageFilePaths)
            {
                string targetName     = Path.GetFileNameWithoutExtension(targetImageTextFilePath);
                TargetImageTextFile t = new TargetImageTextFile(targetName, targetImageTextFilePath, blankCharacter);
                targetImages.Add(t);
            }

            TargetImages = targetImages;
        }