Algorithmix.UnitTest.Helpers.BuildChecker C# (CSharp) Method

BuildChecker() public static method

public static BuildChecker ( string filepath ) : string>.Dictionary
filepath string
return string>.Dictionary
        public static Dictionary<string, string> BuildChecker(string filepath)
        {
            if (!File.Exists(filepath))
            {
                throw new FileNotFoundException("Could not find " + filepath);
            }
            var map = new Dictionary<string, string>();
            var lines = new List<string>(File.ReadAllLines(filepath));
            lines.Where(line => line.Contains(':')).ToList()
                .ForEach(line => map[line.Split(':').First()] = line.Split(':').Last());
            return map;
        }

Usage Example

        public void NaiveKruskalArtificial()
        {
            Shred.BUFFER      = 0;
            Shred.SAMPLE_SIZE = 4;

            var path    = Path.Combine(Drive.GetDriveRoot(), Dir.ArtificialTestDirectory, Dir.NaiveKruskalHttpDocument);
            var shreds  = Shred.Factory("image", path, false);
            var results = Reconstructor.NaiveKruskalAlgorithm(shreds);

            var checker = Helpers.BuildChecker(Path.Combine(path, Helpers.CheckFile));

            shreds.ForEach(shred => Console.Write(" " + shred.Id + ", "));
            Console.WriteLine();
            results.ForEach(shred => Console.Write(" " + shred.Id + ", "));
            Console.WriteLine();

            var indicies = results.Select((t, pos) => new Tuple <int, Shred>(pos, t)).ToList();
            var result   = indicies.Select(pair =>
            {
                var filename = Path.GetFileName(pair.Item2.Filepath);
                Assert.IsNotNull(filename);
                Assert.IsNotNull(checker[filename]);
                var expected = checker[filename];
                var actual   = pair.Item1;
                Console.WriteLine("Actual " + actual + " vs. " + expected + " | File: " + filename);
                return(actual.ToString(CultureInfo.InvariantCulture) == expected);
            }).ToList();

//            var diff = Differ.DiffShredByOrder(results.Select(shred => shred.Id).ToList(),
//Enumerable.Range(0, results.Count).Select(ii => (long)ii).ToList());
//            Console.WriteLine("Difference : " + diff);
            ExportResult((Cluster)shreds.First().Root(), "../../visualizer/NaiveKruskalArtifical.png");
        }
All Usage Examples Of Algorithmix.UnitTest.Helpers::BuildChecker