Exemplo n.º 1
0
        public void GivenUserIsRegisteredInHabitatAndLoggedOut(Table table)
        {
            //Go to Register page
            SiteBase.NavigateToPage(BaseSettings.RegisterPageUrl);
            //Enter data to the fields
            var row = table.Rows.First();

            foreach (var key in row.Keys)
            {
                CommonLocators.RegisterPageFields.GetField(key).SendKeys(row[key]);
            }
            //Following code will remove create user from DB after use case ends
            ContextExtensions.CleanupPool.Add(new TestCleanupAction
            {
                ActionType = ActionType.RemoveUser,
                Payload    = "extranet\\" + row["Email"]
            });
            //Click Register button
            SiteBase.SubmitButton.Click();
            //Actor selects user dialog
            CommonActions.OpenUserDialog();
            //Actor clicks Logout button
            var btn      = "Logout";
            var elements = CommonLocators.UserIconButtons.First(el => el.Text.Equals(btn, StringComparison.InvariantCultureIgnoreCase));

            elements.Click();
        }
Exemplo n.º 2
0
        public string GetResultFileName(SearchFilters searchFilters)
        {
            Log.Instance.Warn("---Begin: GetResultFileName");
            string   fileName = "";
            SiteBase site     = null;

            try
            {
                if (ModelState.IsValid)
                {
                    DbUpdates.PdfCreated(searchFilters, User.Identity.Name);

                    return(fileName = new Rates().GetPdfLocation(site, searchFilters));
                }
                else
                {
                    Log.Instance.Warn("---ModelState not Valid: GetResultFileName");

                    return("");
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error("--- " + ex.Message + "\n " + ex.InnerException + "\n" + ex.StackTrace);
                return("");
            }
        }
Exemplo n.º 3
0
        private string CreatePdf(SiteBase s, Dictionary <string, Dictionary <string, JOffer> > offerMap)
        {
            PdfBuilder pdf = new PdfBuilder(s);

            pdf.CreateHeaders();

            foreach (string link in offerMap.Keys.ToList())
            {
                Dictionary <string, JOffer> map = offerMap[link];
                List <JOffer> offers            = new List <JOffer>();
                if (map.Count > 0)
                {
                    foreach (Category item in Const.categories)
                    {
                        if ((map.ContainsKey(item.Name)) && (map[item.Name] != null))
                        {
                            map[item.Name].SetSiteName(link);
                            offers.Add(map[item.Name]);
                        }
                        else
                        {
                            offers.Add(new JOffer());
                        }
                    }
                }
                pdf.addRow(offers.ToArray());
            }
            pdf.Close();
            return(pdf.fileName);
        }
Exemplo n.º 4
0
        public string Excecute()
        {
            string   brokerName = GetBrokerName(Sf.Source);
            SiteBase site       = null;

            Rates rates = new Rates();
            Dictionary <string, Dictionary <string, JOffer> > pdfRates = rates.GetRates(Sf, out site);

            if (pdfRates.Values.FirstOrDefault().Count > 0)
            {
                for (int i = 0; i < Classes.Count(); i++)
                {
                    List <JOffer> categoryOffers       = GetMiniRatesList(pdfRates, Classes[i].ClassName);
                    List <JOffer> higherCategoryOffers = Classes.Count() > i + 2? GetMiniRatesList(pdfRates, Classes[i + 2].ClassName): null;

                    CsvHelper csvHelper = new CsvHelper(Classes[i].ClassLinkId);

                    List <float> fuseRates = csvHelper.GetFuseRates(brokerName);
                    List <float> priceList = CalculatePrices(categoryOffers, higherCategoryOffers, fuseRates, brokerName);
                    OutputRates(priceList, fuseRates, Classes[i].ClassName);

                    string        body    = csvHelper.GenerateRateString(Sf.PuDate, Sf.DoDate, brokerName, priceList);
                    List <string> brokers = csvHelper.GetFuseBrokers();

                    foreach (string broker in brokers)//rewrite old rates possible unexpected results
                    {
                        if (Sf.ApplyToAll && !(broker.Equals("CTR") || broker.Equals("JIG")))
                        {
                            fuseRates = priceList.Select(s => s * BrokerDiscount(broker)).ToList();
                        }
                        else
                        {
                            fuseRates = csvHelper.GetFuseRates(broker);
                        }
                        body = csvHelper.GenerateRateString(Sf.PuDate, Sf.DoDate, broker, fuseRates, body);
                    }

                    body = csvHelper.GenerateRateString(Sf.PuDate, Sf.DoDate, brokerName, priceList, body);

                    Thread.Sleep(800);

                    string responseText = Request_gmlithuania_fusemetrix_com(Classes[i].ClassLinkId, body);
                    if (responseText.Length < 50)
                    {
                        throw new Exception("Something went wrong");
                    }

                    Thread.Sleep(800);
                }
            }
            return(rates.CreatePdf(site, pdfRates));
        }
Exemplo n.º 5
0
        public void GivenUserWasLoginToHabitat(string btn, Table table)
        {
            SiteBase.NavigateToPage(BaseSettings.LoginPageUrl);

            var row = table.Rows.First();

            foreach (var key in row.Keys)
            {
                Site.LoginPageFields.GetField(key).SendKeys(row[key]);
            }

            var elements = CommonLocators.LoginPageButtons.First(el => el.GetAttribute("value").Contains(btn));

            elements.Click();
        }
Exemplo n.º 6
0
        public Book(string path)
        {
            if (path.IsValidUri())
            {
                onThreadFinish += Book_onThreadFinish;
                url             = new Uri(path);
                this.site       = path.SiteFromString();
                if (!ParseBookFromWeb(path))
                {
                    throw new Exception("Unknown Error: e: bp2 | ParseFromWeb returned false");
                }
            }
            else
            {
                onThreadFinish += Book_onThreadFinish;
                metaData        = new MetaData();
                LoadFromADL(path);
                for (int id = 0; id < chapters.Length; id++)
                {
                    for (int idx = 0; idx < chapters.Length; idx++)
                    {
                        string chr = chapters[idx].name;
                        if (chr.ToArray().FirstLIntegralCount() == 0)
                        {
                            chr += 0;
                        }
                        string chra = chapters[id].name;
                        if (chra.ToArray().FirstLIntegralCount() == 0)
                        {
                            chra += 0;
                        }

                        if (chr.ToCharArray().FirstLIntegralCount() > chra.ToCharArray().FirstLIntegralCount())
                        {
                            Chapter a = chapters[id];
                            chapters[id]  = chapters[idx];
                            chapters[idx] = a;
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the site from the urls through one-one matching.
        /// </summary>
        /// <param name="str"></param>
        /// <returns>Returns Site.{SiteObj} for easy handling.</returns>
        public static SiteBase SiteFromString(this string str)
        {
            Uril main = new Uril(str);

            if (str.IsValidUri())
            {
                SiteBase c = continuity.Where(x => x.chkHost(main.Host)).First();
                if (c == null)
                {
                    throw new NotImplementedException("Based on Domain not implemented TODO");
                }
                else
                {
                    return(c);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        public string SetDates()
        {
            string   brokerName = GetBrokerName(Sf.Location);
            SiteBase site       = null;

            Rates rates = new Rates();

            Dictionary <string, Dictionary <string, JOffer> > pdfRates = rates.GetRates(Sf, out site);

            for (int i = 0; i < Classes.Count(); i++)
            {
                List <JOffer> categoryOffers       = GetMiniRatesList(pdfRates, Classes[i].ClassName);
                List <JOffer> higherCategoryOffers = Classes.Count() > i + 2 ? GetMiniRatesList(pdfRates, Classes[i + 2].ClassName) : null;

                CsvHelper csvHelper = new CsvHelper();

                brokerName = "JIG";
                List <float> priceList = InitiatePrices(categoryOffers, higherCategoryOffers, brokerName, Classes[i].ClassName);

                Log.Instance.Info("INITIATE PRICES:");
                OutputRates(priceList, null, Classes[i].ClassName);
                string body = csvHelper.GenerateRateString(Sf.PuDate, Sf.DoDate, brokerName, priceList);

                brokerName = "CTR";
                priceList  = InitiatePrices(categoryOffers, higherCategoryOffers, brokerName, Classes[i].ClassName);
                body       = csvHelper.GenerateRateString(Sf.PuDate, Sf.DoDate, brokerName, priceList, body);

                Thread.Sleep(800);

                string responseText = Request_gmlithuania_fusemetrix_com(Classes[i].ClassLinkId, body);
                if (responseText.Length < 50)
                {
                    throw new Exception("Something went wrong");
                }

                Thread.Sleep(1000);
            }
            return(rates.CreatePdf(site, pdfRates));
        }
 public void GivenHabitatWebsiteIsOpenedOnRegisterPage()
 {
     SiteBase.NavigateToPage(BaseSettings.RegisterPageUrl);
 }
 public void ThenHabitatWebsiteIsOpenedOnGettingStartedPage()
 {
     SiteBase.NavigateToPage(BaseSettings.GettingStartedPageUrl);
 }
Exemplo n.º 11
0
        public Book(string uri, bool parseFromWeb, int taski, Action <int, string> act, string loc = null, bool loadChapters = true)
        {
            statusUpdate = act;
            ti           = taski;

            if (loc != null)
            {
                root = loc;
            }
            else
            {
                root = Environment.CurrentDirectory;
            }

            if (parseFromWeb)
            {
                if (uri.IsValidUri())
                {
                    onThreadFinish += Book_onThreadFinish;
                    url             = new Uri(uri);
                    this.site       = uri.SiteFromString();
                    if (parseFromWeb)
                    {
                        if (!ParseBookFromWeb(uri))
                        {
                            Console.WriteLine("Can not continue, press enter to exit...");
                            Console.ReadLine();
                            Environment.Exit(-1);
                        }
                    }
                    this.chapterDir = "Chapters/";
                }
                else
                {
                    onThreadFinish += Book_onThreadFinish;
                    url             = new Uri(uri);
                    this.site       = uri.SiteFromString();
                    LoadFromADL(uri, loadChapters);
                    if (parseFromWeb)
                    {
                        if (!ParseBookFromWeb(uri))
                        {
                            Console.WriteLine("Can not continue, press enter to exit...");
                            Console.ReadLine();
                            Environment.Exit(-1);
                        }
                    }
                    this.chapterDir = "Chapters/";
                }
            }
            else
            {
                onThreadFinish += Book_onThreadFinish;
                metaData        = new MetaData();
                LoadFromADL(uri, false, loadChapters);
                if (loadChapters)
                {
                    for (int id = 0; id < chapters.Length; id++)
                    {
                        for (int idx = 0; idx < chapters.Length; idx++)
                        {
                            string chr = chapters[idx].name;
                            if (chr.ToArray().FirstLIntegralCount() == 0)
                            {
                                chr += 0;
                            }
                            string chra = chapters[id].name;
                            if (chra.ToArray().FirstLIntegralCount() == 0)
                            {
                                chra += 0;
                            }

                            if (chr.ToCharArray().FirstLIntegralCount() > chra.ToCharArray().FirstLIntegralCount())
                            {
                                Chapter a = chapters[id];
                                chapters[id]  = chapters[idx];
                                chapters[idx] = a;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
 public void GivenEditProfilePageIsOpened()
 {
     SiteBase.NavigateToPage(BaseSettings.EditUserProfileUrl);
 }
Exemplo n.º 13
0
 public void GivenHabitatWebsiteIsOpenedOnMainPage()
 {
     SiteBase.NavigateToPage(BaseSettings.BaseUrl);
 }
Exemplo n.º 14
0
 public void WhenActorNavigatesToEmployees_ListPage()
 {
     SiteBase.NavigateToPage(BaseSettings.EmployeeList);
 }
 public void WhenActorNavigatesToLoginPage()
 {
     SiteBase.NavigateToPage(BaseSettings.LoginPageUrl);
 }
Exemplo n.º 16
0
 public void GivenMockupOfGooglePageIsOpened()
 {
     SiteBase.NavigateToPage(BaseSettings.DemoSiteURL);
 }
 public void GivenHabitatWebsiteIsOpenedOnForgotPasswordPage()
 {
     SiteBase.NavigateToPage(BaseSettings.ForgotPasswordPageUrl);
 }