public void TestProcessInternalIntegration()
        {
            var saver = Substitute.For <ISaver>();

            var configuration = new Configuration
            {
                MaxDelayGenerator                 = new UniformRandomNumberGenerator(),
                TaskLengthGenerator               = new UniformRandomNumberGenerator(),
                TaskPerTickGenerator              = new UniformRandomNumberGenerator(),
                SimulationLength                  = 10,
                TickLength                        = 10,
                SystemLoad                        = 1m,
                MeanTaskLength                    = 2,
                CoefficientOfVariationTaskLength  = 0,
                MeanMaxDelay                      = 1f,
                CoefficientOfVariationMaxDelay    = 0,
                CoefficientOfVariationTaskPerTick = 0
            };

            var generator = new TaskGenerator(saver, configuration);

            generator.Generate();

            saver.Received().Save(Arg.Is <IEnumerable <TaskModel> >(x => x.Count() == 5));
        }
        public void TestStatisticalParametersOfLargeData()
        {
            const int averageMaxDelay = 12;

            var configuration = new Configuration
            {
                MaxDelayGenerator    = new UniformRandomNumberGenerator(),
                TaskLengthGenerator  = new UniformRandomNumberGenerator(),
                TaskPerTickGenerator = new ParetoTaskPerTickGenerator(),
                SimulationLength     = 1000000,
                TickLength           = 20,
                SystemLoad           = 0.5m,

                MeanTaskLength = 5,
                CoefficientOfVariationTaskLength = 0.2f,

                MeanMaxDelay = 12,
                CoefficientOfVariationMaxDelay = 2f / 3f,

                CoefficientOfVariationTaskPerTick = 0.5f,
            };

            var saver     = new StatisticalValidatorSaver((float)configuration.SystemLoad, configuration.SimulationLength, averageMaxDelay);
            var generator = new TaskGenerator(saver, configuration);

            generator.Generate();
        }
        public void TestGeneratorInManyCases()
        {
            var loads       = Enumerable.Range(0, 5).Select(x => 0.1m + x * 0.2m);
            var taskLengths = new Dictionary <string, int>
            {
                { "short", 5 },
                { "medium", 20 },
                { "long", 40 }
            };
            var taskDelays = new Dictionary <string, float>
            {
                { "short", 5f },
                { "medium", 10f },
                { "long", 15f }
            };
            var coefficientsOfVariations = new[] { 1, 10, 50, 100 };

            var testCases = loads.SelectMany(x => taskLengths, (load, taskLength) => new { load, taskLength })
                            .SelectMany(x => taskDelays, (x, delay) => new { x.load, x.taskLength, delay })
                            .SelectMany(x => coefficientsOfVariations, (x, cov) => new { x.load, x.taskLength, x.delay, cov });

            foreach (var testCase in testCases)
            {
                var configuration = new Configuration
                {
                    MaxDelayGenerator    = new UniformRandomNumberGenerator(),
                    TaskLengthGenerator  = new UniformRandomNumberGenerator(),
                    TaskPerTickGenerator = new ParetoTaskPerTickGenerator(),
                    SimulationLength     = 1000000,
                    TickLength           = 50,
                    SystemLoad           = testCase.load,

                    MeanTaskLength = testCase.taskLength.Value,
                    CoefficientOfVariationTaskLength = 0.2f,

                    MeanMaxDelay = testCase.delay.Value,
                    CoefficientOfVariationMaxDelay = 0.2f,

                    CoefficientOfVariationTaskPerTick = testCase.cov,
                };
                var saver     = new StatisticalValidatorSaver((float)configuration.SystemLoad, configuration.SimulationLength, (int)configuration.MeanMaxDelay);
                var generator = new TaskGenerator(saver, configuration);
                generator.Generate();
            }
        }