Пример #1
0
        public void AddActivityTest()
        {
            //Arrange
            var nickname     = Guid.NewGuid().ToString();
            var activityName = Guid.NewGuid().ToString();
            var rnd          = new Random();

            var userController   = new UserController(nickname);
            var exeActController = new ExerciseActivityController(userController.CurrentUser);
            var activity         = new Activities(activityName, rnd.Next(5, 50));

            //Act
            exeActController.AddActivity(activity, DateTime.Now, DateTime.Now.AddHours(1));

            //Assert
            Assert.AreEqual(activityName, exeActController.Activities.First().ActivityName);
        }
Пример #2
0
        static void Main(string[] args)
        {
            var culture         = CultureInfo.CreateSpecificCulture("en-en");
            var resourceManager = new ResourceManager("FitnessApp.UI.Languages.Messages en-en", typeof(Program).Assembly);

            Console.WriteLine(resourceManager.GetString("Hello", culture));
            Console.WriteLine(resourceManager.GetString("EnterNickname", culture));


            var nickname = Console.ReadLine();

            #region Controllers Initialization
            var userController       = new UserController(nickname);
            var eatingFoodController = new FoodEatingController(userController.CurrentUser);
            var ExActivityController = new ExerciseActivityController(userController.CurrentUser);
            #endregion

            if (userController.IsNewUser)
            {
                Console.WriteLine(resourceManager.GetString("EnterGender", culture));
                var gender    = Console.ReadLine();
                var birhtDate = ParseDateTime("birth date");
                var weight    = ParseToDouble("weight");
                var height    = ParseToDouble("height");


                userController.SetNewUserData(gender, birhtDate, weight, height);
            }
            else
            {
                Console.WriteLine(userController.CurrentUser);
            }

            #region WhatToDo
            while (true)
            {
                Console.WriteLine(resourceManager.GetString("WhatToDo", culture));
                Console.WriteLine(resourceManager.GetString("EnterEating", culture));
                Console.WriteLine(resourceManager.GetString("EnterExercise", culture));
                Console.WriteLine(resourceManager.GetString("SeeInformation"), culture);
                Console.WriteLine(resourceManager.GetString("Exit", culture));
                var key = Console.ReadKey();
                Console.WriteLine();
                switch (key.Key)
                {
                case ConsoleKey.E:
                    var foods = EnterEating();
                    eatingFoodController.Add(foods.Food, foods.Weight);
                    foreach (var item in eatingFoodController.Eating.FoodList)
                    {
                        Console.WriteLine($"\t{item.Key} - {item.Value} gr.");
                    }
                    Console.WriteLine(resourceManager.GetString($"LastEatingDate : {eatingFoodController.Eating.LastTimeEating}", culture));
                    Console.ReadLine();

                    break;

                case ConsoleKey.A:
                    var activities = StartExercises();
                    ExActivityController.AddActivity(activities.Activity, activities.Begin, activities.End);
                    foreach (var item in ExActivityController.Exercises)
                    {
                        Console.WriteLine($"\t {item.Activity.ActivityName}, for : {item.ExFinish - item.ExStart}, " +
                                          $"\t From {item.ExStart.ToShortTimeString()} to {item.ExFinish.ToShortTimeString()}");
                    }
                    break;

                case ConsoleKey.Enter:
                    Console.WriteLine(userController.CurrentUser);
                    break;

                case ConsoleKey.Q:
                    Environment.Exit(1);
                    break;
                }
            }
            #endregion
        }