Ejemplo n.º 1
0
        public void RightLengthArrayInGeneratorArraysTest(long expectedLengthArray)
        {
            var generator = new GeneratorArrays(expectedLengthArray, 2, 1);
            var array     = generator.GenerateArrays()[0];

            Assert.AreEqual(expectedLengthArray, array.Length);
        }
Ejemplo n.º 2
0
        public void RightLengthStrInArrayInGeneratorArraysTest(long expectedLengthStr)
        {
            var generator = new GeneratorArrays(1, expectedLengthStr, 1);
            var str       = generator.GenerateArrays()[0][0];

            Assert.AreEqual(expectedLengthStr, str.Length);
        }
Ejemplo n.º 3
0
        public void RightCountArrayInGeneratorArraysTest(long expectedCountArrays)
        {
            var generator = new GeneratorArrays(2, 2, expectedCountArrays);
            var arrays    = generator.GenerateArrays();

            Assert.AreEqual(arrays.Length, expectedCountArrays);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter path to file .json format:");
            var pathToJson = Console.ReadLine();

            Console.WriteLine("Enter path to save file:");
            var pathToSaveFile   = Console.ReadLine();
            var file             = new StreamReader(pathToJson);
            var json             = file.ReadToEnd();
            var jObject          = JObject.Parse(json);
            var results          = jObject["experiments"]?.Children().ToList();
            var experimentModels = results
                                   .Select(item => item.ToObject <ExperimentModel>())
                                   .ToList();
            var resultsSorted = new Dictionary <long, long>();

            foreach (var experimentModel in experimentModels)
            {
                var generator = new GeneratorArrays(experimentModel.LengthArray,
                                                    experimentModel.LengthStrInArray,
                                                    experimentModel.CountArrays);
                var experimentsArrays = generator.GenerateArrays();
                var allCountOperation = experimentsArrays
                                        .Sum(array => new Sorter(array).Sorted());
                resultsSorted.Add(experimentModel.LengthArray, allCountOperation);
            }

            var builder = new StringBuilder();

            foreach (var(lengthArray, countOperation) in resultsSorted)
            {
                builder.Append(lengthArray + " " + countOperation + "\n");
            }

            var writer = new StreamWriter(pathToSaveFile,
                                          false, Encoding.Default);

            Console.WriteLine(builder.ToString());
            writer.Write(builder.ToString());
        }