Exemple #1
0
        public void BasicGroupingTest()
        {
            var builder = new ServiceLocatorFluent().CreateContainer();

            var mockWeatherhistoryStorage = new Mock <WeatherHistoryStorage>();

            mockWeatherhistoryStorage.Setup(storage => storage.GetAll()).Returns(
                new List <WeatherHistory>
            {
                new WeatherHistory {
                    Day = 0, TrianglePerimeter = 10, Weather = WeatherCondition.Drought
                },
                new WeatherHistory {
                    Day = 1, TrianglePerimeter = 20, Weather = WeatherCondition.STP
                },
                new WeatherHistory {
                    Day = 2, TrianglePerimeter = 30, Weather = WeatherCondition.Drought
                },
                new WeatherHistory {
                    Day = 3, TrianglePerimeter = 40, Weather = WeatherCondition.Unknown
                },
                new WeatherHistory {
                    Day = 4, TrianglePerimeter = 50, Weather = WeatherCondition.Rainy
                },
            });
            var container = builder.Register(mockWeatherhistoryStorage.Object).Build();
            var service   = container.Resolve <WeatherHistoryService>();
            var stats     = service.GetStats();

            Assert.Equal(stats.MaxTrianglePerimter, 50);
            Assert.Equal(stats.DroughtPeriods, 2);
        }
Exemple #2
0
        /// <summary>
        /// Mains the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            var options = new ProcessOption();

            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                var container = new ServiceLocatorFluent().CreateContainer().Build();

                var application = container.Resolve <IProcessManager>();

                application.ExecuteProcess(container, options);
            }
        }
Exemple #3
0
        /// <summary>
        /// Executes the process.
        /// </summary>
        /// <param name="processOption">The process option.</param>
        ///
        public void ExecuteProcess(ServiceLocatorFluent container, ProcessOption processOption)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var previousColor = Console.ForegroundColor;

            try
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("The process is preparing to execute");
                var processes = container.Resolve <IEnumerable <IProcessBase> >();
                var process   = processes.FirstOrDefault(p => string.Compare(p.ExecutionKey(), processOption.Batch, StringComparison.OrdinalIgnoreCase) == 0);
                if (process != null)
                {
                    if (process.HasUniqueExecution())
                    {
                        process.Execute(0);
                    }
                    else
                    {
                        for (var i = 0; i < processOption.Days; i++)
                        {
                            if (i % processOption.DeliveryResume == 0)
                            {
                                Console.WriteLine($"Executing process #{i} of {processOption.Days}");
                            }
                            process.Execute(i);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("The process does not exists");
                }
                Console.WriteLine("The execution was succesfully");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"An error was ocurre: {ex.Message}");
            }
            Console.ForegroundColor = previousColor;
            stopWatch.Stop();
            Console.WriteLine($"Time Elapsed: {stopWatch.ElapsedMilliseconds / 1000} seconds");
        }
Exemple #4
0
        /// <summary>
        /// Setups this instance.
        /// </summary>
        public GalaxyServiceTest()
        {
            var galaxy = new Galaxy {
                Id = 1
            };

            _planets = new List <Planet>
            {
                new Planet {
                    Angle = 1, Galaxy = galaxy, Id = 1, Name = "Moq Planet #1", Radious = 500
                },
                new Planet {
                    Angle = 3, Galaxy = galaxy, Id = 2, Name = "Moq Planet #2", Radious = 2000
                },
                new Planet {
                    Angle = -5, Galaxy = galaxy, Id = 3, Name = "Moq Planet #3", Radious = 1000
                }
            };
            _container = new ServiceLocatorFluent().CreateContainer().Build();
        }