Beispiel #1
0
        public void GetMinEnergyTimeTest_MinEnergyIsReturned()
        {
            var expected = new DateTime(2019, 10, 13);

            var actual = _analyzer.GetMinEnergyTime();

            Assert.Equal(expected, actual);
        }
 public async Task <DateTime> GetMinEnergyTimeAsync()
 => await Task.Run(() => _analizer.GetMinEnergyTime());
Beispiel #3
0
        private static void ShowAnalizerResult(IEnergyObservationAnalizer analizer)
        {
            Console.Clear();
            Console.WriteLine("Select and press 'Enter' button:");
            Console.WriteLine("1 - GetAverageEnergy");
            Console.WriteLine("2 - GetDistributionByCoordinates");
            Console.WriteLine("3 - GetDistributionByEnergyValue");
            Console.WriteLine("4 - GetDistributionByObservationTime");
            Console.WriteLine("5 - GetMaxEnergy");
            Console.WriteLine("6 - GetMaxEnergyPosition");
            Console.WriteLine("7 - GetMaxEnergyTime");
            Console.WriteLine("8 - GetMinEnergy");
            Console.WriteLine("9 - GetMinEnergyPosition");
            Console.WriteLine("10 - GetMinEnergyTime");
            Console.WriteLine("something another - exit");

            var exit = false;

            while (!exit)
            {
                int menuIndex  = 0;
                var userChoice = Console.ReadLine();
                var isParsed   = int.TryParse(userChoice, out menuIndex);
                if (isParsed)
                {
                    switch (menuIndex)
                    {
                    case 1:
                        Console.WriteLine(" Average energy is: " + analizer.GetAverageEnergy());
                        break;

                    case 2:
                        Console.WriteLine("Distribution by coordinates is:");
                        analizer.GetDistributionByCoordinates().PrintDistribution("Coordinates");
                        break;

                    case 3:
                        Console.WriteLine("Distribution by energy value is:");
                        analizer.GetDistributionByEnergyValue().PrintDistribution("Energy value");
                        break;

                    case 4:
                        Console.WriteLine("Distribution by observation time is:");
                        analizer.GetDistributionByObservationTime().PrintDistribution("Observation time");
                        break;

                    case 5:
                        Console.WriteLine(" Max energy is: " + analizer.GetMaxEnergy());
                        break;

                    case 6:
                        Console.WriteLine(" Max energy position is: " + analizer.GetMaxEnergyPosition());
                        break;

                    case 7:
                        Console.WriteLine(" Max energyTime is: " + analizer.GetMaxEnergyTime());
                        break;

                    case 8:
                        Console.WriteLine(" Min energy is: " + analizer.GetMinEnergy());
                        break;

                    case 9:
                        Console.WriteLine(" Position of min energy is: " + analizer.GetMinEnergyPosition());
                        break;

                    case 10:
                        Console.WriteLine(" Time of min energy is: " + analizer.GetMinEnergyTime());
                        break;
                    }
                }
                else
                {
                    exit = true;
                    Console.Clear();
                    ShowMainMenu();
                }
            }
        }
Beispiel #4
0
        private static void ProcessAnalyzer(IEnergyObservationAnalizer analizer)
        {
            Console.Clear();
            Console.WriteLine("Choose method");
            Console.WriteLine("1 - GetAverageEnergy");
            Console.WriteLine("2 - GetDistributionByCoordinates");
            Console.WriteLine("3 - GetDistributionByEnergyValue");
            Console.WriteLine("4 - GetDistributionByObservationTime");
            Console.WriteLine("5 - GetMaxEnergy");
            Console.WriteLine("6 - GetMaxEnergyPosition");
            Console.WriteLine("7 - GetMaxEnergyTime");
            Console.WriteLine("8 - GetMinEnergy");
            Console.WriteLine("9 - GetMinEnergyPosition");
            Console.WriteLine("10 - GetMinEnergyTime");
            Console.WriteLine("Anything else to exit");

            var userChoiceToExit = false;

            while (!userChoiceToExit)
            {
                if (TryReadUserInput(0, 10, out int userChoice))
                {
                    switch (userChoice)
                    {
                    case 1:
                        Console.WriteLine(analizer.GetAverageEnergy());
                        break;

                    case 2:
                        WriteLineDictionary(analizer.GetDistributionByCoordinates());
                        break;

                    case 3:
                        WriteLineDictionary(analizer.GetDistributionByEnergyValue());
                        break;

                    case 4:
                        WriteLineDictionary(analizer.GetDistributionByObservationTime());
                        break;

                    case 5:
                        Console.WriteLine(analizer.GetMaxEnergy());
                        break;

                    case 6:
                        Console.WriteLine(analizer.GetMaxEnergyPosition());
                        break;

                    case 7:
                        Console.WriteLine(analizer.GetMaxEnergyTime());
                        break;

                    case 8:
                        Console.WriteLine(analizer.GetMinEnergy());
                        break;

                    case 9:
                        Console.WriteLine(analizer.GetMinEnergyPosition());
                        break;

                    case 10:
                        Console.WriteLine(analizer.GetMinEnergyTime());
                        break;
                    }
                }
                else
                {
                    userChoiceToExit = true;
                }
            }
        }
Beispiel #5
0
 public DateTime GetMinEnergyTime() => LoggerHelper.RunWithLogging(_logger,
                                                                   () => _innerAnalyzer.GetMinEnergyTime(), nameof(GetMinEnergyTime));
Beispiel #6
0
 public IActionResult GetMinEnergyTime()
 {
     return(this.Ok(_analyzer.GetMinEnergyTime()));
 }