public void AddTest() { // Arrange var userName = Guid.NewGuid().ToString(); var foodName = Guid.NewGuid().ToString(); var rnd = new Random(); var userController = new UserController(userName); var mealController = new MealController(userController.CurrentUser); var food = new Food(foodName, rnd.Next(50, 500), rnd.Next(50, 500), rnd.Next(50, 500), rnd.Next(50, 500)); //Act mealController.Add(food, 100); //Assert Assert.AreEqual(food.Name, mealController.Meal.Foods.First().Key.Name); }
static void Main(string[] args) { CultureInfo culture = CultureInfo.CreateSpecificCulture("ru-ru"); ResourceManager resourceManager = new ResourceManager("BodyBuilder.CMD.Languages.Message", typeof(Program).Assembly); Console.WriteLine(resourceManager.GetString("Greeting", culture)); Console.Write(resourceManager.GetString("EnterUserName", culture)); string name = Console.ReadLine(); UserController userController = new UserController(name); MealController eatingController = new MealController(userController.CurrentUser); ExerciseController exercisesController = new ExerciseController(userController.CurrentUser); if (userController.IsNewUser) { Console.Write(resourceManager.GetString("EnterUserGender", culture)); string gender = Console.ReadLine(); DateTime dateOfBirth = ParseDateTime("дата рождения"); double weight = ParseDouble("вес"); double height = ParseDouble("рост"); userController.SetNewUserData(dateOfBirth, gender, weight, height); } Console.WriteLine(userController.CurrentUser); while (true) { Console.WriteLine("Что Вы хотите сделать?"); Console.WriteLine("E - ввести прием пищи."); Console.WriteLine("A - внести упражнение."); Console.WriteLine("Q - выход."); ConsoleKeyInfo key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.E: var foods = EnterEating(); eatingController.Add(foods.Food, foods.Weight); foreach (var item in eatingController.Meal.Foods) { Console.WriteLine($"\t{item.Key} - {item.Value}"); } break; case ConsoleKey.A: var exercise = EnterExercise(); exercisesController.Add(exercise.Activity, exercise.Begin, exercise.End); foreach (var item in exercisesController.Exercises) { Console.WriteLine($"\t{item.Activity} c {item.Start.ToShortTimeString()} до {item.Finish.ToShortTimeString()}"); } break; case ConsoleKey.Q: Environment.Exit(0); break; } Console.ReadLine(); } }
static void Main(string[] args) { var culture = CultureInfo.CreateSpecificCulture("ru-ru"); var resourceManager = new ResourceManager("FitnessTestApp.CLI.Languages.Messages", typeof(Program).Assembly); Console.WriteLine(resourceManager.GetString("Hello", culture)); Console.Write(resourceManager.GetString("EnterName", culture)); var name = Console.ReadLine(); var userController = new UserController(name); var mealController = new MealController(userController.CurrentUser); var exerciseController = new ExerciseController(userController.CurrentUser); if (userController.IsNewUser) { Console.Write(resourceManager.GetString("EnterGender", culture)); var genderName = Console.ReadLine(); var birthDate = ParseDateTime("дата рождения"); var weight = ParseDouble("вес"); var height = ParseDouble("рост"); userController.SetNewUserData(genderName, birthDate, weight, height); } Console.WriteLine(userController.CurrentUser); while (true) { Console.WriteLine("Что вы хотите сделать?"); Console.WriteLine("M - ввести прием пищи"); Console.WriteLine("A - ввести упражнение"); Console.WriteLine("Q - выход"); var key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.M: var food = EnterMeal(); mealController.Add(food.Food, food.Weight); foreach (var item in mealController.Meal.Foods) { Console.WriteLine($"\t{item.Key} - {item.Value}"); } break; case ConsoleKey.A: var exercise = EnterExercise(); exerciseController.Add(exercise.Activity, exercise.Start, exercise.Finish); foreach (var item in exerciseController.Exercises) { Console.WriteLine($"\t{item.Activity.Name} c {item.Start.ToShortTimeString()} до {item.Finish.ToShortTimeString()}"); } break; case ConsoleKey.Q: Environment.Exit(0); break; } Console.ReadLine(); } }
static void Main(string[] args) { var culture = CultureInfo.CreateSpecificCulture("en-en"); var resourceManager = new ResourceManager("EugineFitness.CMD.Languages.Messages", typeof(Program).Assembly); Console.WriteLine(resourceManager.GetString("Hello", culture)); Console.WriteLine(resourceManager.GetString("EnterUsername", culture)); var name = Console.ReadLine(); var userController = new UserController(name); var mealController = new MealController(userController.CurrentUser); var exerciseController = new ExerciseController(userController.CurrentUser); if (userController.IsNewUser) { Console.WriteLine("Enter your Gender."); var gender = Console.ReadLine(); var birthDate = ParseDateTime("birthday date"); var weight = ParseDouble("weight"); var height = ParseDouble("height"); userController.SetNewUserData(gender, birthDate, weight, height); } Console.WriteLine(userController.CurrentUser); while (true) { Console.WriteLine("What do you want?"); Console.WriteLine("E - enter a meal"); Console.WriteLine("A - enter an activity"); Console.WriteLine("Q - exit"); var key = Console.ReadKey(); Console.WriteLine(); switch (key.Key) { case ConsoleKey.E: var foods = EnterMeal(); mealController.Add(foods.Food, foods.Weight); foreach (var item in mealController.Meal.Foods) { Console.WriteLine($"\t{item.Key} - {item.Value}"); } break; case ConsoleKey.A: var exercises = EnterExercise(); exerciseController.Add(exercises.activity, exercises.begin, exercises.end); foreach (var item in exerciseController.Exercises) { Console.WriteLine($"\t{item.Activity} from {item.Start.ToShortTimeString()} till {item.End.ToShortTimeString()}"); } break; case ConsoleKey.Q: Environment.Exit(0); break; } Console.ReadLine(); } }