Пример #1
0
        public void WhenDateTimeIsPassedThenWeStoreOnlyDateInAListOfCommentRecordType()
        {
            var fields         = new FieldSplitter();
            var commentRecords = new List <string> {
                "1/1/2020 12:30"
            };
            var records   = fields.SplitFields(commentRecords);
            var condition = true;

            foreach (var record in records)
            {
                var condition1 = record.DateTime.Equals("1/1/2020 12:30");
                var condition2 = record.Comment.Equals("");
                condition = condition && condition1 && condition2;
            }
            Assert.True(condition);
        }
Пример #2
0
        public void WhenBothTimestampAndCommentIsPassedThenStoreBothInAListOfCommentRecordType()
        {
            var fields         = new FieldSplitter();
            var commentRecords = new List <string> {
                "1/1/2020 12:30,Code should be decoupled"
            };
            var records   = fields.SplitFields(commentRecords);
            var condition = true;

            foreach (var record in records)
            {
                var condition1 = record.DateTime.Equals("1/1/2020 12:30");
                var condition2 = record.Comment.Equals("Code should be decoupled");
                condition = condition && condition1 && condition2;
            }
            Assert.True(condition);
        }
        public void ReturnSplitFieldFromString()
        {
            var fieldSplitter = new FieldSplitter();
            var field         = "~~~\n" +
                                "44\n" +
                                "*...\n" +
                                "....\n" +
                                ".*..\n" +
                                "....\n" +
                                "~~~\n" +
                                "\n" +
                                "~~~\n" +
                                "35\n" +
                                "**...\n" +
                                ".....\n" +
                                ".*...\n" +
                                "~~~";
            var actual   = fieldSplitter.Split(field);
            var expected = new List <string>
            {
                "~~~\n" +
                "44\n" +
                "*...\n" +
                "....\n" +
                ".*..\n" +
                "....\n" +
                "~~~",

                "~~~\n" +
                "35\n" +
                "**...\n" +
                ".....\n" +
                ".*...\n" +
                "~~~"
            };

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
 public MineSweeper()
 {
     _fieldSplitter  = new FieldSplitter();
     _fieldFormatter = new FieldFormatter();
 }
Пример #5
0
        //arg0 = fileIn
        //arg1 = NumOfDivisions
        //arg2 = MeshHeader
        //arg3 = Resolution
        //arg4 = ThreadCount
        //arg5 = x axis
        //arg6 = y axis
        //arg7 = z axis
        //arg8 = isoLevel
        //args9+ = headers to split
        public static void Main(string[] args)
        {
            DebugLog.setDebug(true);
            DebugLog.resetLog();
            DebugLog.logConsole("RAM : " + SystemRecommendations.getRAM().ToString() + " b");
            DebugLog.logConsole("Physical Cores : " + SystemRecommendations.getCores().ToString());
            DebugLog.logConsole("CPU : " + SystemRecommendations.getHz().ToString() + " Hz");
            DebugLog.logConsole("Recommended resolution : " + SystemRecommendations.getRecommendedResolution().ToString());

            string toBeParsed = null;
            string meshHeader = args[2];

            string[] axis = new string[] { args[5], args[6], args[7] };
            if (args.Length < 10)
            {
                Console.Out.WriteLine("Incorrect number of Args. run with --help to see doc");
                Console.In.ReadLine();
                return;
            }
            if (args.Length == 1 && (args[0].ToLower() == "--help" || args[0].ToLower() == "help" || args[0].ToLower() == "?" || args[0].ToLower() == "h"))
            {
                Console.Out.WriteLine(help);
                Console.In.ReadLine();
                return;
            }
            if (!File.Exists(args[0]))
            {
                DebugLog.logConsole("File not found. Are you sure you typed the right file name?");
                throw new Exception("File not found. Are you sure you typed the right file name?");
            }
            else
            {
                toBeParsed = args[0];
            }

            DebugLog.logConsole("Recommended threads : " + SystemRecommendations.getRecommendedThreads(FileParser.estimatedNumberOfEntries(toBeParsed)).ToString());
            if (!Int32.TryParse(args[1], out int numOfDivisions))
            {
                DebugLog.logConsole("divisionNumber was not a number");
                throw new Exception("divisionNumber was not a number");
            }
            if (!Int32.TryParse(args[3], out int resolution))
            {
                DebugLog.logConsole("resolution given was not a number");
                throw new Exception("resolution given was not a number");
            }
            if (!Int32.TryParse(args[4], out int threadCount))
            {
                DebugLog.logConsole("thread count given was not a number");
                throw new Exception("thread count given was not a number");
            }
            if (!float.TryParse(args[8], out float isoLevel))
            {
                DebugLog.logConsole("isoLevel given was not a number");
                throw new Exception("isoLevel given was not a number");
            }
            if (resolution < 0 || threadCount < 0 || isoLevel < 0f || numOfDivisions < 0)
            {
                DebugLog.logConsole("Neither thread count, resolution, isoLevel, nor divNum can be negative");
                throw new Exception("Neither thread count, resolution, isoLevel, nor divNum can be negative");
            }

            #region ALL
            DateTime now = DateTime.Now;
            //first we parse

            FileParser.parseDataIntoCache(toBeParsed);
            DebugLog.logConsole("Time to finish Parsing : " + (DateTime.Now - now).TotalMinutes.ToString());

            now = DateTime.Now;
            //This is what it will be in the cache
            string nameNotPath = Path.GetFileNameWithoutExtension(toBeParsed);
            //now we split the file


            if (args.Length < 8)
            {
                FieldSplitter.splitFileAll(nameNotPath, numOfDivisions);
            }
            else
            {
                string[] headers = new string[args.Length - 9];
                for (int i = 9; i < args.Length; i++)
                {
                    headers[i - 9] = args[i];
                }
                FieldSplitter.splitFileGiven(nameNotPath, headers, numOfDivisions);
            }


            DebugLog.logConsole("Time to finish file splitting : " + (DateTime.Now - now).TotalMinutes.ToString());

            DebugLog.logConsole("Beginnging mesh creation");
            //now we create the meshes for a header
            //for (int i = 200000; i < resolution; i += 200000)
            //{
            now = DateTime.Now;
            AllMeshes.allFromDivisions(nameNotPath, meshHeader, resolution, threadCount, axis, isoLevel);
            DebugLog.logConsole("Time to finish mesh " + resolution + " : " + (DateTime.Now - now).TotalMinutes.ToString());
            //}
            #endregion
        }