Пример #1
0
        public void CalcBasicChargeTest()
        {
            var dayService = new DayService();

            dayService.CheckService(new Record("2 E1"));
            int basicCharge = dayService.CalcBasicCharge(1000);

            Assert.AreEqual(1200, basicCharge);
        }
Пример #2
0
        public void CheckServiceTest()
        {
            var dayService = new DayService();

            dayService.CheckService("2 C1 090-1234-0001");
            Assert.IsFalse(dayService.IsJoined());

            dayService.CheckService("2 E1");
            Assert.IsTrue(dayService.IsJoined());
        }
Пример #3
0
        public void CalcUnitPriceTest()
        {
            var dayService = new DayService();

            dayService.CheckService("2 E1");
            int unitPrice = dayService.CalcUnitPrice("5 2004/06/05 18:00 010 090-1234-0002", 20);

            Assert.AreEqual(20, unitPrice);
            unitPrice = dayService.CalcUnitPrice("5 2004/06/05 17:59 010 090-1234-0002", 20);
            Assert.AreEqual(15, unitPrice);
        }
Пример #4
0
        public void RecalculateMacrosInMeal_Test()
        {
            //Arrange
            var dayService = new DayService();
            var meal       = new Meal("", 1);

            meal.ProductsInMeal.Add(new ItemInMeal(new Item(1, "", 50, 50, 50, 50, 1), 100));
            //Act
            dayService.RecalculateMacrosInMeal(meal);
            //Assert
            meal.Weight.IsSameOrEqualTo(100);
            meal.TotalKcal.IsSameOrEqualTo(50);
        }
Пример #5
0
        public void IsServiceTimeTest()
        {
            var dayService = new DayService();

            Assert.IsFalse(dayService.IsServiceTime(7));
            Assert.IsFalse(dayService.IsServiceTime(8));
            Assert.IsFalse(dayService.IsServiceTime(17));
            Assert.IsFalse(dayService.IsServiceTime(18));

            dayService.Joined();
            Assert.IsFalse(dayService.IsServiceTime(7));
            Assert.IsTrue(dayService.IsServiceTime(8));
            Assert.IsTrue(dayService.IsServiceTime(17));
            Assert.IsFalse(dayService.IsServiceTime(18));
        }
Пример #6
0
        public void RecalculateMacrosInDay_Test()
        {
            //Arrange
            var dayService  = new DayService();
            var mealService = new MealService();
            var day         = new Day(new DateTime(2020, 10, 15), 1);

            dayService.Items.Add(day);
            day.mealList = dayService.AddDomainMealsToDay(mealService);
            day.mealList[0].ProductsInMeal.Add(new ItemInMeal(new Item(1, "", 100, 100, 100, 100, 1), 9000));
            dayService.RecalculateMacrosInMeal(day.mealList[0]);
            //Act
            dayService.RecalculateMacrosInDay(day);
            //Assert
            day.TotalKcal.IsSameOrEqualTo(900000);
        }
Пример #7
0
        public void CreateNewDayByDateTime_Test()
        {
            //Arrange
            var dayService = new DayService();
            var mock       = new Mock <MealService>();

            dayService.Items.Add(new Day(new DateTime(2020, 10, 10), 100));
            var dateTime = new DateTime(2020, 08, 18);

            //Act
            var outputTrue = dayService.CreateNewDayByDateTime(dateTime, mock.Object);

            //Assert
            outputTrue.Should().NotBeNull();
            outputTrue.Should().BeOfType <Day>();
            outputTrue.Id.Should().IsSameOrEqualTo(101);
            dayService.Items.Should().Contain(outputTrue);
        }
Пример #8
0
        public void AddDomainMealsInDay()
        {
            //Arrange
            var dayService  = new DayService();
            var mealService = new MealService();
            //Act
            var output = dayService.AddDomainMealsToDay(mealService);

            //Assert
            output.Should().NotBeNullOrEmpty();
            output.Length.Should().Be(6);
            output[0].NameOfMeal.Should().Be("Breakfast");
            output[1].NameOfMeal.Should().Be("Second Breakfast");
            output[2].NameOfMeal.Should().Be("Lunch");
            output[3].NameOfMeal.Should().Be("Midday Meal");
            output[4].NameOfMeal.Should().Be("Snack");
            output[5].NameOfMeal.Should().Be("Dinner");
        }
Пример #9
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
            {
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            });
            var context = services.BuildServiceProvider().GetService <ApplicationDbContext>();


            var telegramBot = new TelegramBot(context);
            var dayService  = new DayService(telegramBot, context);

            services.AddSingleton(telegramBot);
            services.AddSingleton(dayService);
            // services.AddSingleton<TelegramBot>();
            // services.AddSingleton<DayService>();
            // services.AddSingleton(new DayService((TelegramBot)serviceProvider.GetService(typeof(TelegramBot)), (ApplicationDbContext)serviceProvider.GetService(typeof(ApplicationDbContext))));
            services.AddDatabaseDeveloperPageExceptionFilter();
        }
Пример #10
0
        static void Main(string[] args)
        {
            //Initialize required services
            var printService        = new ConsolePrinter();
            var itemService         = new ItemService();
            var dayService          = new DayService(printService);
            var agedBrieService     = new AgedBrieService(itemService);
            var backstageService    = new BackstageService(itemService);
            var normalItemService   = new NormalItemService(itemService);
            var conjuredItemService = new ConjuredItemService(itemService);
            //Get all items
            var items = itemService.CreateItems();
            //Create app with all business logic
            var app = new GildedRoseClass(items, agedBrieService, backstageService, normalItemService, conjuredItemService);
            //Print all 30 days results
            var thirtyDaysService = new ThirtyDaysService(printService, dayService, app);

            thirtyDaysService.PrintThirtyDaysItemsResults(items);
        }
Пример #11
0
        public void AddProductToMeal()
        {
            //Arrange
            var itemInMeal  = new ItemInMeal(new Item(10, "name", 100, 100, 100, 100, 0), 50);
            var day         = new Day(new DateTime(2020, 12, 12), 10);
            var dayService  = new DayService();
            var mealService = new MealService();

            day.mealList = dayService.AddDomainMealsToDay(mealService);
            //Act
            var output = dayService.AddProductToMeal(itemInMeal, day.mealList[0], day);

            //Assert
            output.Should().NotBe(null);
            day.mealList[0].Should().NotBe(null);
            day.mealList[0].NameOfMeal.Should().BeSameAs("Breakfast");
            day.mealList[0].ProductsInMeal.Should().NotBeNullOrEmpty();
            day.mealList[0].ProductsInMeal.Should().Contain(itemInMeal);
        }
Пример #12
0
        private void BtnAddToPlan_Clicked(object sender, EventArgs e)
        {
            try
            {
                var dayService = new DayService();

                dayService.SaveDayPlan(
                    new Request.SaveDayPlanRequest
                {
                    Date      = PlanDate.Date,
                    RecipeId  = _recipeId,
                    UserEmail = "*****@*****.**"
                });

                DisplayAlert("Sucesso", "Receita adicionada com sucesso", "Ok");
            }
            catch (Exception)
            {
                DisplayAlert("Erro", "Não foi possível adicionar a receita", "Ok");
            }
        }
Пример #13
0
    /// <summary>
    /// Initializes a new instance of the <see cref="GeneratedWeekViewModel"/> class.
    /// </summary>
    /// <param name="dialogService">Dialog service dependency.</param>
    /// <param name="regionManager">Region manager for Prism navigation.</param>
    /// <param name="recipeService">Recipe service dependency.</param>
    /// <param name="container">IoC container.</param>
    /// <param name="dayService">Day service dependency.</param>
    public GeneratedWeekViewModel(DialogService dialogService,
                                  IRegionManager regionManager,
                                  RecipeService recipeService,
                                  IContainerExtension container,
                                  DayService dayService)
    {
        this.dialogService = dialogService;
        this.regionManager = regionManager;
        this.recipeService = recipeService;
        this.container     = container;
        this.dayService    = dayService;

        ReturnCommand = new DelegateCommand(Return);
        DeleteRecipeManuallyCommand  = new DelegateCommand <DayPlan>(DeleteRecipeManually);
        SetRecipeManuallyCommand     = new AsyncDelegateCommand <DayPlan>(SetRecipeManuallyAsync);
        SetGarnishManuallyCommand    = new AsyncDelegateCommand <DayPlan>(SetGarnishManuallyAsync, canExecute: (day) => day?.Recipe?.Garnishes.Count > 1);
        GetAlternativeRecipeCommand  = new DelegateCommand <DayPlan>(GetAlternativeRecipe, canExecute: (day) => day?.RecipeAlternatives?.Count > 1);
        GetAlternativeGarnishCommand = new DelegateCommand <DayPlan>(GetAlternativeGarnish, canExecute: (day) => day?.Recipe?.Garnishes.Count > 1);
        ShowRecipeCommand            = new DelegateCommand <Guid>(ShowRecipe);
        CloseCommand = new DelegateCommand(Close);
        OkCommand    = new AsyncDelegateCommand(OkAsync);
    }
Пример #14
0
        public void HowManyMealsAreVisibleInDay()
        {
            //Arrange
            var day         = new Day(new DateTime(2020, 12, 12), 10);
            var dayService  = new DayService();
            var mealService = new MealService();

            day.mealList = dayService.AddDomainMealsToDay(mealService);
            //Act
            var outputFull = dayService.HowManyMealsAreVisibleInDay(day);

            day.mealList[0].IsVisible = false;
            day.mealList[1].IsVisible = false;
            day.mealList[2].IsVisible = false;
            day.mealList[3].IsVisible = false;
            day.mealList[4].IsVisible = false;
            day.mealList[5].IsVisible = false;
            var outputNull = dayService.HowManyMealsAreVisibleInDay(day);

            //Assert
            outputFull.Should().Be(6);
            outputNull.Should().Be(0);
        }
Пример #15
0
 public DiaryResponse(Diary diary)
 {
     Id              = diary.Id;
     StartDate       = diary.StartDate;
     EndDate         = diary.EndDate;
     Conclusions     = diary.Conclusions;
     BenchPressStart = diary.BenchPressStart;
     SquatStart      = diary.SquatStart;
     DeadliftStart   = diary.DeadliftStart;
     BenchPressEnd   = diary.BenchPressEnd;
     SquatEnd        = diary.SquatEnd;
     DeadliftEnd     = diary.DeadliftEnd;
     Progress        = diary.Progress;
     if (diary.Days != null)
     {
         Days = new List <DayResponse>();
         DayService dayService = new DayService();
         foreach (var day in diary.Days)
         {
             Days.Add(dayService.GetDay(day.Id));
         }
     }
 }
Пример #16
0
        public void HideMeal_Test()
        {
            //Arrange
            var itemInMeal  = new ItemInMeal(new Item(10, "name", 100, 100, 100, 100, 0), 50);
            var day         = new Day(new DateTime(2020, 12, 12), 10);
            var dayService  = new DayService();
            var mealService = new MealService();

            day.mealList = dayService.AddDomainMealsToDay(mealService);
            //Act
            var outputTrue  = dayService.HideMeal(day.mealList[0], day);
            var outputFalse = dayService.HideMeal(day.mealList[0], day);

            dayService.HideMeal(day.mealList[1], day);
            dayService.HideMeal(day.mealList[2], day);
            dayService.HideMeal(day.mealList[3], day);
            dayService.HideMeal(day.mealList[4], day);
            var outputVisibleDaysAreLessThanTwo = dayService.HideMeal(day.mealList[5], day);

            //Assert
            outputTrue.Should().Be(day.mealList[0].Id);
            outputFalse.Should().Be(-1);
            outputVisibleDaysAreLessThanTwo.Should().Be(-2);
        }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SampleDataController"/> class.
 /// </summary>
 /// <param name="dayService"><see cref="WeekService"/>.</param>
 public SampleDataController(DayService dayService)
 {
     this.dayService = dayService;
 }
Пример #18
0
        static void Main(string[] args)
        {
            MenuActionService           actionService   = new MenuActionService();
            IItemService <Item>         itemService     = new ItemService();
            ICategoryService <Category> categoryService = new CategoryService();
            MealService     mealService     = new MealService();
            DayService      dayService      = new DayService();
            ItemManager     itemManager     = new ItemManager(categoryService, itemService);
            CategoryManager categoryManager = new CategoryManager(categoryService, itemService);
            MealManager     mealManager     = new MealManager(mealService);
            DayManager      dayManager      = new DayManager(actionService, dayService, mealService);

            Console.WriteLine("Welcome to CountItApp!");

            bool exitApp;

            do
            {
                Console.WriteLine("What You want to do:");
                var mainMenu = actionService.GetMenuActrionsByMenuName("MainMenu");
                foreach (var item in mainMenu)
                {
                    Console.WriteLine($"{item.Id}. {item.Name}");
                }
                exitApp = false;
                var  operation = Console.ReadKey();
                bool isBackButtonPressed;
                switch (operation.KeyChar)
                {
                case '1':
                    do
                    {
                        var keyInfo = categoryManager.CategoryServiceView(actionService);
                        isBackButtonPressed = false;
                        switch (keyInfo.KeyChar)
                        {
                        case '1':
                            categoryManager.AddNewCategory();
                            break;

                        case '2':
                            itemManager.AddNewItem(categoryManager);
                            break;

                        case '3':
                            itemManager.SignProductToCategory(categoryManager);
                            break;

                        case '4':
                            categoryManager.DeleteCategory();
                            break;

                        case '5':
                            itemManager.DeleteProduct();
                            break;

                        case '6':
                            categoryManager.WievAllCategories();
                            break;

                        case '7':
                            itemManager.ShowAllProducts();
                            break;

                        case '8':
                            Console.Clear();
                            itemManager.ShowAllProductsFromChoosenCategory(categoryManager);
                            break;

                        case '9':
                            isBackButtonPressed = true;
                            break;

                        default:
                            Console.WriteLine("Please choose right operation!");
                            break;
                        }
                    }while (!isBackButtonPressed);
                    break;

                case '2':
                    do
                    {
                        var keyInfo = dayManager.AddNewDayView();
                        isBackButtonPressed = false;
                        switch (keyInfo.KeyChar)
                        {
                        case '1':
                            dayManager.AddNewDay();
                            break;

                        case '2':
                            dayManager.AddNewMeal();
                            break;

                        case '3':
                            dayManager.AddProductToMeal(itemManager);
                            break;

                        case '4':
                            dayManager.RemoveProductFromMeal(mealManager);
                            break;

                        case '5':
                            dayManager.DeleteDay();
                            break;

                        case '6':
                            dayManager.DeleteMeal();
                            break;

                        case '7':
                            dayManager.ShowDayMacro();
                            break;

                        case '8':
                            dayManager.ShowMealMacro();
                            break;

                        case '9':
                            dayManager.ShowAllDays();
                            break;

                        case '0':
                            dayManager.ShowAllDays();
                            isBackButtonPressed = true;
                            break;

                        default:
                            Console.WriteLine("Please choose right operation!");
                            break;
                        }
                    }while (!isBackButtonPressed);
                    break;

                case '3':
                    exitApp = true;
                    break;

                case '4':
                    //categoryManager.AddNewCategoryMixed();
                    //itemManager.AddNewItemMixed(categoryService, itemService);
                    //itemManager.SignProductToCategoryMixed(categoryService, itemService);
                    //dayManager.AddNewDayMixed();
                    //dayManager.AddNewMealMixed(mealManager, itemManager, dayService);
                    //dayManager.AddProductsToMealsMixed(mealManager, itemManager, itemService);
                    break;

                default:
                    Console.WriteLine("Please choose right operation!");
                    break;
                }
            }while (!exitApp);
        }
 public DayController()
 {
     this._dayService = new DayService();
 }
Пример #20
0
 public DaysController(DayService dayService)
 {
     _dayService = dayService;
 }
Пример #21
0
        public void AddNewMealMixed(MealManager _mealManager, ItemManager _itemManager, DayService _dayService)
        {
            Random rnd = new Random();

            string[] names = { "Breakfast", "Lunch", "Dinner", "Evening food :)" };
            foreach (var item in _dayService.Items)
            {
                for (int i = 0; i < names.Length; i++)
                {
                    item.MealList.Add(new Meal(names[i], rnd.Next(1, 10)));
                }
            }
        }
Пример #22
0
        static void Main(string[] args)
        {
            string filePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            filePath += "\\xmlSettings";
            Directory.CreateDirectory(filePath);
            Console.WriteLine(filePath);

            //Assembly asm = Assembly.GetEntryAssembly();
            //string appDir = Path.GetDirectoryName(asm.Location);
            //string filePath = Path.Combine(appDir, "settings.xml");
            //Console.WriteLine("{0}", filePath + "jestem przed");
            //Console.WriteLine(appDir);
            //Console.ReadLine();
            //Directory.CreateDirectory(filePath + "xdddd");
            //Console.WriteLine("jestem po!");
            //Console.ReadLine();

            MenuActionService actionService = new MenuActionService();

            //IItemService<Item> itemService = new ItemService(Path.Combine(filePath, "items.xml"));
            //ICategoryService<Category> categoryService = new CategoryService(Path.Combine(filePath, "categories.xml"));
            //IDayService<Day> dayService = new DayService(Path.Combine(filePath, "days.xml"));
            //IMealService<Meal> mealService = new MealService(Path.Combine(filePath, "meals.xml"));
            //Console.WriteLine(Path.Combine(filePath, "items.xml"));
            ItemService     itemService     = new ItemService(Path.Combine(filePath, "Items.xml"));
            CategoryService categoryService = new CategoryService(Path.Combine(filePath, "Categories.xml"));
            DayService      dayService      = new DayService(Path.Combine(filePath, "Days.xml"));
            MealService     mealService     = new MealService(Path.Combine(filePath, "Meals.xml"));

            ItemManager     itemManager     = new ItemManager(categoryService, itemService);
            CategoryManager categoryManager = new CategoryManager(categoryService, itemService);
            MealManager     mealManager     = new MealManager();
            DayManager      dayManager      = new DayManager(actionService, dayService, mealService);

            Console.WriteLine("Welcome to CountItApp!");

            bool exitApp;

            do
            {
                Console.WriteLine("What You want to do:");
                var mainMenu = actionService.GetMenuActrionsByMenuName("MainMenu");
                foreach (var item in mainMenu)
                {
                    Console.WriteLine($"{item.Id}. {item.Name}");
                }
                exitApp = false;
                var  operation = Console.ReadKey();
                bool isBackButtonPressed;
                switch (operation.KeyChar)
                {
                case '1':
                    do
                    {
                        var keyInfo = categoryManager.CategoryServiceView(actionService);
                        isBackButtonPressed = false;
                        switch (keyInfo.KeyChar)
                        {
                        case '1':
                            categoryManager.AddNewCategory();
                            break;

                        case '2':
                            itemManager.AddNewItem(categoryManager);
                            break;

                        case '3':
                            itemManager.SignProductToCategory(categoryManager);
                            break;

                        case '4':
                            categoryManager.DeleteCategory();
                            break;

                        case '5':
                            itemManager.DeleteProduct();
                            break;

                        case '6':
                            categoryManager.WievAllCategories();
                            break;

                        case '7':
                            itemManager.ShowAllProducts();
                            break;

                        case '8':
                            Console.Clear();
                            itemManager.ShowAllProductsFromChoosenCategory(categoryManager);
                            break;

                        case '9':
                            isBackButtonPressed = true;
                            break;

                        default:
                            Console.WriteLine("Please choose right operation!");
                            break;
                        }
                    }while (!isBackButtonPressed);
                    break;

                case '2':
                    do
                    {
                        var keyInfo = dayManager.AddNewDayView();
                        isBackButtonPressed = false;
                        switch (keyInfo.KeyChar)
                        {
                        case '1':
                            dayManager.AddNewDay();
                            break;

                        case '2':
                            dayManager.ChangeMealName();
                            break;

                        case '3':
                            dayManager.AddProductToMeal(itemManager);
                            break;

                        case '4':
                            dayManager.RemoveProductFromMeal(mealManager);
                            break;

                        case '5':
                            dayManager.DeleteDay();
                            break;

                        case '6':
                            dayManager.DeleteMeal();
                            break;

                        case '7':
                            dayManager.ShowDayMacro();
                            break;

                        case '8':
                            dayManager.ShowMealMacro();
                            break;

                        case '9':
                            dayManager.ShowAllDays();
                            break;

                        case '0':
                            dayManager.ShowAllDays();
                            isBackButtonPressed = true;
                            break;

                        default:
                            Console.WriteLine("Please choose right operation!");
                            break;
                        }
                    }while (!isBackButtonPressed);
                    break;

                case '3':
                    //ItemService itemService = new ItemService(Path.Combine(filePath, "items.xml"));
                    //ICategoryService<Category> categoryService = new CategoryService(Path.Combine(filePath, "categories.xml"));
                    //IDayService<Day> dayService = new DayService(Path.Combine(filePath, "days.xml"));
                    //IMealService<Meal> mealService = new MealService(Path.Combine(filePath, "meals.xml"));
                    itemService.SaveListToXml("items", Path.Combine(filePath, "Items.xml"));
                    categoryService.SaveListToXml("categories", Path.Combine(filePath, "Categories.xml"));
                    dayService.SaveListToXml("days", Path.Combine(filePath, "Days.xml"));
                    mealService.SaveListToXml("meals", Path.Combine(filePath, "Meals.xml"));
                    exitApp = true;
                    break;

                case '4':
                    //categoryManager.AddNewCategoryMixed();
                    //itemManager.AddNewItemMixed(categoryService, itemService);
                    //itemManager.SignProductToCategoryMixed(categoryService, itemService);
                    //dayManager.AddNewDayMixed();
                    ////dayManager.AddNewMealMixed(mealManager, itemManager, dayService);
                    //dayManager.AddProductsToMealsMixed(mealManager, itemManager, itemService);
                    break;

                default:
                    Console.WriteLine("Please choose right operation!");
                    break;
                }
            }while (!exitApp);
        }