예제 #1
0
        public void LoadsMetadataFileCorrectly(string relativeJsonPath)
        {
            // Act
            var metadata = metatdataLoader.LoadMetadata(new FileInfo(Path.GetFullPath(relativeJsonPath))).ToList();

            Assert.Equal(4, metadata.Count);
            Assert.Equal(3f, metadata.First().FitnessHighscore);
            Assert.Equal(3f, metadata.Last().FitnessHighscore);
        }
예제 #2
0
        public static IGenerationProvider Get(DirectoryInfo directory, IGenerationLoader loader)
        {
            var files = directory.GetFiles();

            if (files.Count(file => file.Name == MetadataFileName) == 1)
            {
                var metatdataLoader = new MetatdataLoader();
                var metadata        = metatdataLoader.LoadMetadata(files.Single(file => file.Name == MetadataFileName));
                var generationInfo  = new Dictionary <GenerationMetadata, FileInfo>(capacity: files.Length - 1);
                var generationFiles = files.Where(file => file.Name != MetadataFileName).ToList();

                for (int i = 0; i < files.Length - 1; i++)
                {
                    generationInfo.Add(metadata[i], generationFiles[i]);
                }

                return(new LazyGenerationProvider(generationInfo, loader));
            }

            return(new GenerationProvider(files.ToList(), loader));
        }