Ejemplo n.º 1
0
        private static int Execute(CommandLineApplication config, IBudgetFilesFactory budgetFilesFactory, ILog log)
        {
            var yearOption     = YearOption.Create(config);
            var monthOption    = MonthOption.Create(config);
            var currencyOption = CurrencyOption.Create(config);

            if (yearOption.NotExists || monthOption.NotExists || currencyOption.NotExists)
            {
                config.ShowHelp();
                return(ErrorCode.Value);
            }

            var(plannedBudgetFile, realBudgetFile) = budgetFilesFactory.Create(yearOption, monthOption, currencyOption);

            if (plannedBudgetFile.NotExists || realBudgetFile.NotExists)
            {
                plannedBudgetFile.Save();
                realBudgetFile.Save();

                log.Write($"Budget {plannedBudgetFile.Budget} has been created.");
                return(OkCode.Value);
            }

            log.Write($"Budget {plannedBudgetFile.Budget} already exists.");
            return(ErrorCode.Value);
        }
Ejemplo n.º 2
0
        public void FillRegistrationForm(RegistrationUser user)
        {
            Type(FirstName, user.FirstName);
            Type(LastName, user.LastName);
            ClickOnElements(MartialStatus, user.MatrialStatus);
            ClickOnElements(Hobbys, user.Hobbys);
            CountryOption.SelectByText(user.Country);
            MounthOption.SelectByText(user.BirthMonth);
            DayOption.SelectByText(user.BirthDay);
            YearOption.SelectByText(user.BirthYear);
            Type(Phone, user.Phone);
            Type(UserName, user.UserName);
            Type(Email, user.Email);

            if (user.Picture != null || user.Picture != string.Empty)
            {
                UploadButton.Click();
                Driver.SwitchTo().ActiveElement().SendKeys(user.Picture);
            }

            Type(Description, user.Description);
            Type(Password, user.Password);
            Type(ConfirmPassword, user.ConfirmPassword);
            SubmitButton.Click();
        }
Ejemplo n.º 3
0
        public AddCommandBuilder(CommandLineApplication application)
        {
            _application = application;

            _yearOption        = YearOption.Create(application);
            _monthOption       = MonthOption.Create(application);
            _currencyOption    = CurrencyOption.Create(application);
            _amountOption      = AmountOption.Create(application);
            _categoryOption    = CategoryOption.Create(application);
            _descriptionOption = DescriptionOption.Create(application);
        }
Ejemplo n.º 4
0
        public (BudgetFile plannedBudgetFile, BudgetFile realBudgetFile) Create(YearOption yearOption, MonthOption monthOption,
                                                                                CurrencyOption currencyOption)
        {
            var month    = Month.Create(yearOption.Value, MonthName.Create(monthOption.Value));
            var currency = Currency.Create(currencyOption.Value);

            var budget = new Budget(month, currency);

            var realBudgetFileName    = new FileName($"budget-{budget.Month.Year}-{budget.Month.MonthName.Index}");
            var plannedBudgetFileName = new FileName($"budget-{budget.Month.Year}-{budget.Month.MonthName.Index}-plan");

            return(plannedBudgetFile : new BudgetFile(budget, plannedBudgetFileName),
                   realBudgetFile : new BudgetFile(budget, realBudgetFileName));
        }
Ejemplo n.º 5
0
 public void FillRegistrationForm(RegistrationUser user)
 {
     Type(FirstName, user.FirstName);
     Type(LastName, user.LastName);
     FillManyOptionElements(MatrialStatus, user.MatrialStatus);
     FillManyOptionElements(Hobbies, user.Hobbies);
     CountryOption.SelectByText(user.Country);
     MonthOption.SelectByValue(user.Month);
     DayOption.SelectByText(user.Day);
     YearOption.SelectByValue(user.Year);
     Type(Phone, user.Phone);
     Type(UserName, user.UserName);
     Type(Email, user.Email);
     UploadPicButton.Click();
     _driver.SwitchTo().ActiveElement().SendKeys(user.PicturePath);
     Type(Description, user.Description);
     Type(Password, user.Password);
     Type(ConfirmPassword, user.ConfirmPassword);
     SubmitButton.Click();
 }
Ejemplo n.º 6
0
 public void FillRegistrationForm()
 {
     Type(FirstName, "Ventsislav");
     Type(LastName, "Ivanov");
     this.MatrialStatus.Click();
     this.Hobbies[0].Click();
     this.Hobbies[1].Click();
     CountryOption.SelectByText("Bulgaria");
     MonthOption.SelectByValue("3");
     DayOption.SelectByText("3");
     YearOption.SelectByValue("1989");
     Type(Phone, "359999999999");
     Type(UserName, "BatmanForever");
     Type(Email, "*****@*****.**");
     UploadPicButton.Click();
     Driver.SwitchTo().ActiveElement().SendKeys(Path.GetFullPath(@"..\..\..\logo.jpg"));
     Type(Description, "I think I'm Ready with this test!");
     Type(Password, "123456789");
     Type(ConfirmPassword, "123456789");
     SubmitButton.Click();
 }
        public void FillForm(User user)
        {
            FirstName.SendKeys(user.FirstName);
            LastName.SendKeys(user.LastName);

            Password.SendKeys(user.Password);
            Days.Click();
            DayOption.Click();
            Months.Click();
            MonthOption.Click();
            Years.Click();
            YearOption.Click();
            Address.SendKeys(user.Address);
            City.SendKeys(user.City);
            State.Click();
            StateOption.Click();
            Zip.SendKeys(user.ZipCode);

            HomePhone.SendKeys(user.HomePhone);
            Mobile.SendKeys(user.MobilePhone);
            AddressAlias.Clear();
            AddressAlias.SendKeys(user.AddressAlias);
            RegisterButton.Click();
        }
Ejemplo n.º 8
0
        private static int Run(string[] args)
        {
            var app    = new CommandLineApplication();
            var budget = app.Command("budget", config =>
            {
                config.HelpOption(HelpFlagTemplate.Value);
            });

            budget.Command("create", config =>
            {
                config.Name        = "create";
                config.Description = "create budget providing year, month and currency";
                config.HelpOption(HelpFlagTemplate.Value);

                var yearOption     = YearOption.Create(config);
                var monthOption    = MonthOption.Create(config);
                var currencyOption = CurrencyOption.Create(config);

                config.OnExecute(() =>
                {
                    if (yearOption.NotExists || monthOption.NotExists || currencyOption.NotExists)
                    {
                        config.ShowHelp();
                        return(ErrorCode.Value);
                    }

                    var budgetFilesFactory = new BudgetFilesFactory();
                    var(plannedBudgetFile, realBudgetFile) = budgetFilesFactory.Create(yearOption, monthOption, currencyOption);

                    if (plannedBudgetFile.NotExists || realBudgetFile.NotExists)
                    {
                        plannedBudgetFile.Save();
                        realBudgetFile.Save();

                        Console.WriteLine($"Budget {plannedBudgetFile.Budget} has been created.");
                        return(OkCode.Value);
                    }

                    Console.WriteLine($"Budget {plannedBudgetFile.Budget} already exists.");

                    return(OkCode.Value);
                });
            });

            budget.Command("add", config =>
            {
                config.Name        = "add";
                config.Description = "add revenue or expense to budget";
                config.HelpOption(HelpFlagTemplate.Value);

                var yearOption        = YearOption.Create(config);
                var monthOption       = MonthOption.Create(config);
                var currencyOption    = CurrencyOption.Create(config);
                var amountOption      = AmountOption.Create(config);
                var categoryOption    = CategoryOption.Create(config);
                var descriptionOption = DescriptionOption.Create(config);

                config.OnExecute(() =>
                {
                    if (yearOption.NotExists ||
                        monthOption.NotExists ||
                        currencyOption.NotExists ||
                        amountOption.NotExists ||
                        categoryOption.NotExists ||
                        descriptionOption.NotExists)
                    {
                        config.ShowHelp();
                        return(ErrorCode.Value);
                    }

                    var budgetFilesFactory = new BudgetFilesFactory();
                    var(plannedBudgetFile, realBudgetFile) = budgetFilesFactory.Create(yearOption, monthOption, currencyOption);

                    if (realBudgetFile.NotExists)
                    {
                        Console.WriteLine($"Budget {realBudgetFile.Budget} does not exit. Created new budget first.");
                        return(ErrorCode.Value);
                    }

                    var budgetFile = realBudgetFile.Load();

                    var category    = Category.Create(categoryOption.Value);
                    var description = new Description(descriptionOption.Value);
                    var currency    = Currency.Create(currencyOption.Value);
                    var amount      = Amount.Create(amountOption.Value, currency);

                    var newBudget     = budgetFile.Budget.WithExpense(new Money(amount, category, DateTimeOffset.UtcNow, description));
                    var newBudgetFile = new BudgetFile(newBudget, budgetFile.FileName);

                    newBudgetFile.Save();

                    Console.WriteLine("Expense added.");
                    return(OkCode.Value);
                });
            });


//            var budget = new BudgetCommandBuilder(app).Build();
//
//            new CreateBudgetCommandBuilder(budget).Build();
//            new BudgetsListCommandBuilder(budget).Build();
//            new AddCommandBuilder(budget).Build();

            return(app.Execute(args));
        }