Пример #1
0
        public void ParseDecimal()
        {
            var expected = TableExtensions.ParseDecimal(Value);

            Assert.AreEqual(5.6m, expected);
            Assert.Throws <ArgumentException>(() => TableExtensions.ParseDecimal(""));
        }
Пример #2
0
 public void TryParseInt()
 {
     TableExtensions.TryParseInt("700", out var expected);
     int.TryParse("700", NumberStyles.Number, CultureInfo.NumberFormat, out var wrong);
     Assert.AreEqual(700, wrong);
     Assert.AreEqual(700, expected);
 }
Пример #3
0
        public void Update(GameConfigSheet.Row row)
        {
            switch (row.Key)
            {
            case "hourglass_per_block":
                HourglassPerBlock = TableExtensions.ParseInt(row.Value);
                break;

            case "action_point_max":
                ActionPointMax = TableExtensions.ParseInt(row.Value);
                break;

            case "daily_reward_interval":
                DailyRewardInterval = TableExtensions.ParseInt(row.Value);
                break;

            case "daily_arena_interval":
                DailyArenaInterval = TableExtensions.ParseInt(row.Value);
                break;

            case "weekly_arena_interval":
                WeeklyArenaInterval = TableExtensions.ParseInt(row.Value);
                break;
            }
        }
Пример #4
0
        public void ParseLong()
        {
            var expected = TableExtensions.ParseLong("700");

            Assert.AreEqual(700, expected);
            Assert.Throws <ArgumentException>(() => TableExtensions.ParseLong(""));
        }
Пример #5
0
 public void TryParseFloat()
 {
     TableExtensions.TryParseFloat(Value, out var expected);
     float.TryParse(Value, NumberStyles.Number, CultureInfo.NumberFormat, out var wrong);
     Assert.AreEqual(56f, wrong);
     Assert.AreEqual(5.6f, expected);
 }
Пример #6
0
        public void DadoPreenchiTodosOsCampos(Table table)
        {
            var dictionary    = TableExtensions.ToDictionary(table);
            var nomeCompleto  = dictionary["nomeCompleto"];
            var email         = dictionary["email"];
            var data          = dictionary["data"];
            var horas         = dictionary["horas"];
            var minutos       = dictionary["minutos"];
            var sobremesa     = dictionary["sobremesa"];
            var cor           = dictionary["cor"];
            var comida        = dictionary["comida"];
            var notaAnimal    = dictionary["notaAnimal"];
            var notaFutebol   = dictionary["notaFutebol"];
            var notaBaseball  = dictionary["notaBaseball"];
            var notaeSports   = dictionary["notaeSports"];
            var notaRugby     = dictionary["notaRugby"];
            var tipoSanduiche = dictionary["tipoSanduiche"];

            _pageObject.
            PreencherCampoNomeCompleto(dictionary["nomeCompleto"]).
            PreencherCampoEmail(dictionary["email"]).
            SelecionarCorFavorita(dictionary["cor"]).
            SelecionarSobremesaFavorita(dictionary["sobremesa"]).
            SelecionarComidaFavorita(dictionary["comida"]).
            SelecionarNotaAnimais(dictionary["notaAnimal"]).
            SelecionarNotasEsportes(notaFutebol: dictionary["notaFutebol"], notaBaseball: dictionary["notaBaseball"], notaeSports: dictionary["notaeSports"], notaRugby: dictionary["notaRugby"]).
            SelecionarIngredientesSanduiches(dictionary["tipoSanduiche"]).
            PreencherCampoData(dataAtual).
            PreencherHoraAtual(horaAtual, minutoAtual);
        }
Пример #7
0
        public void WhenIInputTheFollowingInformation(Table user)
        {
            var dictionary = TableExtensions.ToDictionary(user);

            _username = dictionary["Email"].ToString();
            _password = dictionary["Password"].ToString();
        }
Пример #8
0
 public void TryParseDecimal()
 {
     TableExtensions.TryParseDecimal(Value, out var expected);
     decimal.TryParse(Value, NumberStyles.Number, CultureInfo.NumberFormat, out var wrong);
     Assert.AreEqual(56m, wrong);
     Assert.AreEqual(5.6m, expected);
 }
        public void ThenISeeSearchingResultPage(Table table)
        {
            string brandCar     = table.Rows[0]["Brand"];
            string modelCar     = table.Rows[0]["Model"];
            string startYearCar = table.Rows[0]["StartYear"];
            string endYearCar   = table.Rows[0]["EndYear"];

            var dataTable = TableExtensions.ToDataTable(table);

            foreach (DataRow row in dataTable.Rows)
            {
                Console.WriteLine(row.ItemArray[0].ToString());
                Console.WriteLine(row.ItemArray[1].ToString());
                Console.WriteLine(row.ItemArray[2].ToString());
                Console.WriteLine(row.ItemArray[3].ToString());
            }

            foreach (var car in filteringPage.carTitles)
            {
                Assert.That(car.FindElement(By.XPath("./span")).Text.Contains(brandCar + " " + modelCar),
                            "The actual brand and model of the car is search result does not according to set filtering");

                string[] wordsInTitle  = car.Text.Split(' ');
                int      actualYearCar = int.Parse(wordsInTitle[wordsInTitle.Length - 1]);
                if (actualYearCar > int.Parse(endYearCar) || actualYearCar < int.Parse(startYearCar))
                {
                    throw new AssertionException("The actual year of the car is search result does not according to set filtering");
                }
            }
        }
        public void WhenPreenchoOsCampos(Table table)
        {
            cadastroCursosPage = new CadastroCursosPage(_driver);

            var dictionary = TableExtensions.ToDictionary(table);

            cadastroCursosPage.PreencherCamposPasso1(dictionary["Titulo"], dictionary["Descricao"]);
        }
Пример #11
0
        public virtual async Task <bool> InitAsync()
        {
            _table = await TableExtensions
                     .CreateTableClientAsync(
                _credentials, TableName, true, _logger)
                     .ConfigureAwait(false);

            return(_table != null);
        }
Пример #12
0
        public void WhenUserEnterCrendentials(Table table)
        {
            // ScenarioContext.Current.Pending();
            var dictionary = TableExtensions.ToDictionary(table);
            var test       = dictionary["Username"];

            driver.FindElement(By.XPath("//input[@id='UserName']")).SendKeys(dictionary["Username"]);
            driver.FindElement(By.XPath("//input[@id='Password']")).SendKeys(dictionary["Password"]);
        }
Пример #13
0
        public void insertUserInfomationToDB(Table user)
        {
            var uInfo = TableExtensions.ToDictionary(user);

            using (var item = new AccountController())
            {
                item.Register(uInfo["Fullname"].ToString(), uInfo["Email"].ToString(), uInfo["Phone"].ToString(), uInfo["Address"].ToString(), uInfo["Password"].ToString(), uInfo["Password"].ToString());
            }
        }
Пример #14
0
        public void WhenIInputTheFollowingInformation(Table User)
        {
            var dictionary = TableExtensions.ToDictionary(User);

            _username = dictionary["Email"].ToString();
            string _password = dictionary["Password"].ToString();

            Browser.SetTextBoxValue("email", _username);
            Browser.SetTextBoxValue("password", _password);
        }
Пример #15
0
        public void Update(GameConfigSheet.Row row)
        {
            switch (row.Key)
            {
            case "hourglass_per_block":
                HourglassPerBlock = TableExtensions.ParseInt(row.Value);
                break;

            case "action_point_max":
                ActionPointMax = TableExtensions.ParseInt(row.Value);
                break;
            }
        }
        public void WhenEnterCredentials(Table table)
        {
            var dataTable = TableExtensions.ToDataTable(table);

            foreach (DataRow row in dataTable.Rows)
            {
                driver.FindElement(By.Id("username")).SendKeys(row.ItemArray[0].ToString());
                driver.FindElement(By.Id("password")).SendKeys(row.ItemArray[1].ToString());
                //driver.FindElement(By.Name("login")).Click();
                // driver.FindElement(By.Id("username")).Clear();
                //driver.FindElement(By.Id("password")).Clear();
            }
        }
Пример #17
0
        public bool checkLogged(Table user)
        {
            var sID = TableExtensions.ToDictionary(user);

            using (var item = new AccountController())
            {
                _sessionName = item.Session["FullName"].ToString();
            }
            if (_sessionName == sID["SessionID"])
            {
                return(true);
            }
            return(false);
        }
Пример #18
0
        public void CreatePerson(Table Person)
        {
            var dictionary = TableExtensions.ToDictionary(Person);
            var test       = dictionary["Identifier"];

            WaitForElementText("//div[@class='modal-header']/h4", "Create Person");
            driver.FindElement(By.Name("identifiername")).SendKeys(dictionary["Identifier"]);
            driver.FindElement(By.Name("firstname")).SendKeys(dictionary["Firstname"]);
            driver.FindElement(By.Name("lastname")).SendKeys(dictionary["Lastname"]);

            SelectElement Organization = new SelectElement(driver.FindElement(By.XPath("//SELECT[@data-ng-options='organization.ID as organization.Description for organization in ctrl.organizations']['Operator Machine']")));

            Organization.SelectByValue("0");

            WaitingForElement("//div[@class='modal-body']/div[1]/div[12]/div/input");
            driver.FindElement(By.XPath("//div[@class='modal-body']/div[1]/div[12]/div/input")).Click();
        }
Пример #19
0
        public void ConvertKeyTypeMismatch()
        {
            var pks = new[]
            {
                new PrimaryKeyInformation
                {
                    Name = "pk1",
                    Type = typeof(int)
                }
            };

            var keys = new object[]
            {
                "abc"
            };

            TableExtensions.GetTableKeys(pks, keys);
        }
        public void WhenIFillInNewEmployeeDataWithTheFollowing(Table table)
        {
            dynamic newEmployee        = table.CreateDynamicInstance();
            var     employeeManagement = ScenarioContext.Current.Get <EmployeeManagementPage>();

            if (newEmployee.StartDate.ToString() == "Today")
            {
                employeeManagement.FillInNewEmployeeData(newEmployee.FirstName, newEmployee.LastName, DateTime.Now.Date.ToString("yyyy-MM-dd"), newEmployee.Email);
            }
            else
            {
                var dictionary = TableExtensions.ToDictionary(table);
                ScenarioContext.Current.Remove("StartDate");
                ScenarioContext.Current.Add("StartDate", dictionary["Start date"]);
                string startDate = ScenarioContext.Current.Get <string>("StartDate");
                employeeManagement.FillInNewEmployeeData(newEmployee.FirstName, newEmployee.LastName, startDate, newEmployee.Email);
            }
        }
Пример #21
0
        public void ConvertKeyTypeMatches()
        {
            var pks = new[]
            {
                new PrimaryKeyInformation
                {
                    Name = "pk1",
                    Type = typeof(int)
                }
            };

            var keys = new object[]
            {
                "1"
            };

            TableExtensions.GetTableKeys(pks, keys);

            Assert.AreEqual(1, pks[0].Value);
        }
Пример #22
0
        public void inputPropertyInfo(Table property)
        {
            var propInfo = TableExtensions.ToDictionary(property);

            K21T1_Team3Entities db = new K21T1_Team3Entities();

            _prop.PropertyName    = propInfo["PropertyName"].ToString();
            _prop.PropertyType_ID = int.Parse(propInfo["PropertyType_ID"].ToString());
            _prop.Content         = propInfo["Content"].ToString();
            _prop.Street_ID       = int.Parse(propInfo["Street_ID"].ToString());
            _prop.Ward_ID         = int.Parse(propInfo["Ward_ID"].ToString());
            _prop.District_ID     = int.Parse(propInfo["District_ID"].ToString());
            _prop.Price           = int.Parse(propInfo["Price"].ToString());
            _prop.UnitPrice       = propInfo["UnitPrice"].ToString();
            _prop.Area            = propInfo["Area"].ToString();
            _prop.BedRoom         = int.Parse(propInfo["BedRoom"].ToString());
            _prop.BathRoom        = int.Parse(propInfo["Bathroom"].ToString());
            _prop.PackingPlace    = int.Parse(propInfo["PackingPlace"].ToString());
            _prop.UserID          = int.Parse(propInfo["UserId"].ToString());
            _prop.Status_ID       = int.Parse(propInfo["Status_ID"].ToString());
        }
Пример #23
0
        /// <summary>
        /// Runs the SQL.
        /// </summary>
        /// <param name="sqlCommand">The SQL command.</param>
        /// <param name="sqlParams">The SQL parameters.</param>
        /// <param name="storedProcedure">if set to <c>true</c> [stored procedure].</param>
        /// <param name="statusText">The status text.</param>
        public void RunSQL(string sqlCommand, List <SqlParameter> sqlParams, bool storedProcedure, out string statusText)
        {
            statusText = string.Empty;
            try
            {
                // remove any existing commands
                Session.RemoveAll();
                if (_trigger != null)
                {
                    _trigger.Dispose();
                }

                // create command and assign delegate handlers
                _trigger            = new LogTrigger();
                _trigger.LogEvent  += new LogTrigger.InfoMessage(LogEvent);
                _trigger.connection = new SqlConnection(TableExtensions.GetConnectionString());
                _trigger.command    = new SqlCommand(sqlCommand);

                if (storedProcedure)
                {
                    _trigger.command.CommandType = CommandType.StoredProcedure;
                }

                foreach (var param in sqlParams)
                {
                    _trigger.command.Parameters.Add(param);
                }

                // start the command and the timer
                _trigger.Start();
                tmrSyncSQL.Enabled = true;
                Session["trigger"] = _trigger;
            }
            catch (Exception ex)
            {
                statusText += string.Format("Could not connect to the database. {0}<br>", ex.Message);
            }
        }
Пример #24
0
        public void ThenICanEditTheUserProfile(Table editProfileTable)
        {
            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.EditProfileButton.Click();
            Sync.ExplicitWait(1);

            var dictionary = TableExtensions.ToDictionary(editProfileTable);

            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.FirstNameField.Clear();
            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.FirstNameField.SendKeys(dictionary["FirstName"]);
            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.LastNameField.Clear();
            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.LastNameField.SendKeys(dictionary["LastName"]);
            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.PhoneField.Clear();
            Sync.ExplicitWait(1);
            AppointmentManagerPages.MyProfilePage.PhoneField.SendKeys(dictionary["Phone"]);

            Sync.ExplicitWait(2);
            AppointmentManagerPages.MyProfilePage.UpdateInfoButton.Click();
        }
 public void WhenUserEntersFollowing(string p, Table table)
 {
     TableExtensions.InitializeScenarioContext(table);
     pages.ORTSmokeTcsPage.AddReportParameters();
 }
Пример #26
0
        /// <summary>
        /// Transforms the file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public bool TransformFile(string filePath, out string tableName, out string errors)
        {
            var       transformResult = false;
            DataTable tableToUpload   = null;

            tableName = string.Empty;
            errors    = string.Empty;

            if (!File.Exists(filePath))
            {
                filePath = this.Request.MapPath(filePath);
                var fileInfo = new FileInfo(filePath);

                using (var stream = File.OpenRead(filePath))
                {
                    if (fileInfo.Extension.Equals(".csv", StringComparison.CurrentCultureIgnoreCase))
                    {
                        using (var pack = new CsvReader(new StreamReader(stream)))
                        {
                            tableToUpload = pack.TransformTable();
                        }
                    }

                    if (fileInfo.Extension.Equals(".xls", StringComparison.CurrentCultureIgnoreCase) || fileInfo.Extension.Equals(".xlsx", StringComparison.CurrentCultureIgnoreCase))
                    {
                        using (ExcelPackage pack = new ExcelPackage(stream))
                        {
                            tableToUpload = pack.TransformTable();
                        }
                    }
                }

                if (tableToUpload != null)
                {
                    // generate the table creation
                    tableToUpload.TableName = fileInfo.Name.Replace(fileInfo.Extension, "");
                    tableToUpload.TableName = tableToUpload.TableName.RemoveSpecialCharacters();
                    tableToUpload.TableName = "_rocks_kfs_" + tableToUpload.TableName;
                    var sb = new System.Text.StringBuilder(
                        string.Format(@"IF EXISTS
                                    ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}')
                                    DROP TABLE [{0}];
                                    CREATE TABLE [{0}] (", tableToUpload.TableName));
                    foreach (DataColumn column in tableToUpload.Columns)
                    {
                        sb.Append(" [" + column.ColumnName.RemoveSpecialCharacters() + "] " + TableExtensions.GetSQLType(column) + ",");
                    }

                    var createTableScript = sb.ToString().TrimEnd(new char[] { ',' }) + ")";
                    RunSQL(createTableScript, new List <SqlParameter>(), false, out errors);

                    // wait for the table to be created
                    Thread.Sleep(1000);

                    var conn = ConfigurationManager.ConnectionStrings["RockContext"].ConnectionString;
                    using (var bulkCopy = new SqlBulkCopy(conn))
                    {
                        bulkCopy.DestinationTableName = string.Format("[{0}]", tableToUpload.TableName);
                        try
                        {
                            foreach (var column in tableToUpload.Columns)
                            {
                                // use the original column to map headers, but trim in SQL
                                bulkCopy.ColumnMappings.Add(column.ToString(), column.ToString().RemoveSpecialCharacters());
                            }
                            bulkCopy.WriteToServer(tableToUpload);
                        }
                        catch (Exception ex)
                        {
                            errors = ex.Message;
                        }
                    }

                    if (string.IsNullOrWhiteSpace(errors))
                    {
                        transformResult = true;
                        tableName       = tableToUpload.TableName;
                    }
                }

                // cleanup whether we could read the file or not
                File.Delete(filePath);
            }

            return(transformResult);
        }
 public void WhenUserEntersFollowingToCreateBlankReport(string p0, Table table)
 {
     TableExtensions.InitializeScenarioContext(table);
     pages.ORTSmokeTcsPage.EnterReportDetails();
     pages.ORTSmokeTcsPage.Waits.WaitForPageLoad();
 }
 public void WhenEnterFollowingToImportReport(string type, Table table)
 {
     ScenarioContext.Current["Type"] = type;
     TableExtensions.InitializeScenarioContext(table);
     pages.ORTSmokeTcsPage.EnterOMBDetailsToCreateReport();
 }
 public void WhenUserEntersAsFollows(string type, Table table)
 {
     ScenarioContext.Current["Type"] = type;
     TableExtensions.InitializeScenarioContext(table);
     pages.ORTSmokeTcsPage.AddSupportFormDetails();
 }
Пример #30
0
        private MigraDoc.DocumentObjectModel.Tables.Table AddTable(IPdfStyling pdfStyling, Section section)
        {
            // This is a little bit faky, otherwise we can't add spaces before and after table
            if (this._spaceBefore > 0 || this._spaceAfter > 0)
            {
                IPdfElement pdfSpace = new PdfSpace(this._spaceBefore, this._spaceAfter);
                pdfSpace.Render(pdfStyling: pdfStyling, section: section);
            }

            // Add table to the section
            MigraDoc.DocumentObjectModel.Tables.Table table = section.AddTable();

            // This is a little bit faky, otherwise we can't add spaces before and after table
            if (this._spaceBefore > 0 || this._spaceAfter > 0)
            {
                IPdfElement pdfSpace = new PdfSpace(this._spaceBefore, this._spaceAfter);
                pdfSpace.Render(pdfStyling: pdfStyling, section: section);
            }

            //THead (and Columns)

            // Calculate widths if necessary
            double[] widths = TableExtensions.CalculateColumnWidths(
                pdfStyling: pdfStyling,
                document: section.Document,
                tHead: this.THead,
                tBody: this.TBody,
                fitToDocument: _fitToDocument);

            // Create columns from THead
            Column column;

            for (int c = 0; c < this.THead.Count; c++)
            {
                column = table.AddColumn(new Unit(widths[c]));
                column.Format.Alignment = this.THead[c].Alignment.GetAlignment();
            }

            // Create the header of the table
            Row thead;

            if (this.THead.Any(o => string.IsNullOrWhiteSpace(o.Text.Trim())) == false)
            {
                //HINT: If an error appears here because you did not added PdfTableHeaderCells -> you have to add but with empty strings :-)
                thead            = table.AddRow();
                thead.TopPadding = Unit.FromPoint(5);
                //titleRow.BottomPadding = Unit.FromPoint(5);
                thead.HeadingFormat = true;

                for (int i = 0; i < this.THead.Count; i++)
                {
                    AddText(
                        pdfStyling: pdfStyling,
                        pdfCell: this.THead[i],
                        cell: thead.Cells[i]);

                    thead.Cells[i].VerticalAlignment = VerticalAlignment.Top;
                    thead.Cells[i].Style             = PdfStyleNames.Table.THead;
                }
            }

            //TBody

            for (int i = 0; i < this.TBody.Count; i++)
            {
                AddCell(
                    pdfStyling: pdfStyling,
                    table: table,
                    pdfRow: this.TBody[i],
                    isTFoot: false);
            }

            //TFoot

            for (int i = 0; i < this.TFoot.Count; i++)
            {
                AddCell(
                    pdfStyling: pdfStyling,
                    table: table,
                    pdfRow: this.TFoot[i],
                    isTFoot: true);
            }

            return(table);
        }