public static ElementsList InitializeElements(string locator, SearchBy locatorValue = SearchBy.Xpath) { ElementsList elements = new ElementsList(); elements.Search = new Search(locator); return(elements); }
public void AssertGridCells() { // Verify all cells using a function with Assert TestGrid.ForEachCell(cell => cell.AssertFontSize("14px")); // Get Cell by Column name TestGrid.GetCell("Firstname", 1).ValidateInnerTextIs("Mary"); // Get Cell by Cell coordinates TestGrid.GetCell(0, 1).ValidateInnerTextIs("John"); // Get a cell that is equal to an Object property TestGrid.GetCell <Employee>(cell => cell.PersonalEmail, 1).ValidateInnerTextIs("*****@*****.**"); // Get all cells that satisfy a condition using a function ElementsList <TableCell> matchingCells = TestGrid.GetCells <TableCell>(cell => cell.InnerText.StartsWith('J')); Assert.AreEqual(2, matchingCells.Count()); // Get cell with multiple-row headers TestGrid.GetCell("Email Business", 0).ValidateInnerTextIs("*****@*****.**"); // Perform actions in cell elements var firstRowEmail = TestGrid.GetRow(0).GetCell("Email Personal"); TestGrid.GetCell("Actions", 0).As <Button>().Click(); var firstRowEmailAfterDelete = TestGrid.GetRow(0).GetCell("Email Personal"); Assert.AreNotEqual(firstRowEmail, firstRowEmailAfterDelete); }
/// <summary> /// Adds new position into matrix /// </summary> /// <param name="position">Position</param> public override void Add(Position <T> position) { if (position == null) { throw new ArgumentNullException("The argument is null"); } if (ElementsList.Count > 0) { if (!AreTheSameType(ElementsList.Last(), position)) { throw new ArgumentException("All positions should be the same type"); } if (IsMatrix3D()) { if (!Check3DMatrix(ElementsList.Last(), position)) { string message = "For 3D matrix amount of data points in each position should be equal."; throw new ArgumentException(message); } } } base.AddElement(position); }
/// <summary> /// Adds new element to the collection /// </summary> /// <param name="container">Element for adding</param> public override void Add(Container <T> container) { if (container == null) { throw new ArgumentNullException("The argument is null"); } if (ElementsList.Count > 0) { var lastContainer = ElementsList.Last(); if (CheckContainersOnMatrixAmount(container, lastContainer) && CheckTypeOfEachIndexedMatrix(container, lastContainer) && CheckNumberofDataPointsIn3dMatrix(container, lastContainer)) { base.AddElement(container); } else { string message = "Each container should have the same number of matrix and each indexed matrix should have the same type"; throw new ArgumentException(message); } } else { base.AddElement(container); } }
//Convert the list to a dictionary public void ToDictionary(ElementsList el) { foreach (var item in el.Words) { MyDictionary.Add(item.Word, item.Definition); } }
public void Simulate(double timeModeling) { int prev = -1; while (TCurrent < timeModeling) { TNext = Double.MaxValue; foreach (var e in ElementsList) { if (e.TNext < TNext) { TNext = e.TNext; Event = ElementsList.IndexOf(e); } } ManageChannels(); if (!(prev == 0 && Event == 0)) { Console.WriteLine($"It's time for event in {ElementsList[Event].Name} , time = {ElementsList[Event].TNext}"); } foreach (var e in ElementsList) { if (e.GetType() == typeof(Doctor)) { Doctor d = (Doctor)e; if (d.States.Count > 0) { d.DoStatistics(TNext - TCurrent, d.States[0]); } else { d.DoStatistics(TNext - TCurrent, 0); } } else { e.CountStatistics(TNext - TCurrent); } } TCurrent = TNext; foreach (var e in ElementsList) { e.TCurrent = TCurrent; } //Get(Event).OutAct(); ElementsList[Event].OutAct(); foreach (var e in ElementsList) { if (e.TNext == TCurrent) { e.OutAct(); } } //PrintInfo(); } PrintResult(); }
private void _read() { _len = m_io.ReadS4le(); __raw_fields = m_io.ReadBytes((Len - 5)); var io___raw_fields = new KaitaiStream(__raw_fields); _fields = new ElementsList(io___raw_fields, this, m_root); _terminator = m_io.EnsureFixedContents(new byte[] { 0 }); }
private void _read() { _len = m_io.ReadS4le(); __raw_fields = m_io.ReadBytes((Len - 5)); var io___raw_fields = new KaitaiStream(__raw_fields); _fields = new ElementsList(io___raw_fields, this, m_root); _terminator = m_io.ReadBytes(1); if (!((KaitaiStream.ByteArrayCompare(Terminator, new byte[] { 0 }) == 0))) { throw new ValidationNotEqualError(new byte[] { 0 }, Terminator, M_Io, "/seq/2"); } }
public void AssertHeaders() { // You can get all table header rows through the TableHeaderRows property. Table.TableHeaderRows.ForEach(header => header.AssertFontFamily("\"Times New Roman\"")); // As a shortcut, you can iterate over the header rows through the ForEachHeader method. Table.ForEachHeader(row => row.AssertFontFamily("\"Times New Roman\"")); // You can get all table header cells through the ColumnHeaders property. ElementsList <Label> headerCells = Table.ColumnHeaders; headerCells.ForEach(cell => cell.AssertFontSize("16px")); }
public Level02() { AsstesList.Add(new Images.Tray()); AsstesList.Add(new Images.Reload(new Position(Dimensions.Canvas.Width - Dimensions.Element.Width, 0))); AsstesList.Add(new Images.Simulate(new Position(0, 0))); var trayGatesList = new List <Gate>(); trayGatesList.Add(new GateXNOR(new Position(0, 0))); // trayGatesList.Add(new GateNAND(new Position(0, 0))); trayGatesList.Add(new GateNOT(new Position(0, 0))); foreach (var gate in trayGatesList) { gate.Position.Width = (Dimensions.Canvas.Width / 2) - (trayGatesList.Count * gate.Size.Width / 2) - ((trayGatesList.Count - 2) * 8) + (trayGatesList.IndexOf(gate) * (gate.Size.Width + Dimensions.Space.Width)); GatesList.Add(gate); } var logicSourcesList = new List <Source>(); logicSourcesList.Add(new Source(new Position((Dimensions.Element.Width / 4) + Dimensions.Element.Width, 0), Defs.Element.High)); logicSourcesList.Add(new Source(new Position((Dimensions.Element.Width / 4) + Dimensions.Element.Width, 0), Defs.Element.Low)); foreach (var source in logicSourcesList) { source.Position.Height = (Dimensions.Canvas.Height / 2) - (logicSourcesList.Count * source.Size.Height / 2) - (Dimensions.Element.Height / 4) + (logicSourcesList.IndexOf(source) * source.Size.Height); ElementsList.Add(source); } var lampsList = new List <Lamp>(); lampsList.Add(new Lamp(new Position(Dimensions.Canvas.Width - ((Dimensions.Element.Width / 4) + Dimensions.Element.Width * 4), 0), Defs.Element.Low)); foreach (var lamp in lampsList) { lamp.Position.Height = (Dimensions.Canvas.Height / 2) - (lampsList.Count * lamp.Size.Height / 2) - (Dimensions.Element.Height / 4) + (lampsList.IndexOf(lamp) * lamp.Size.Height); LampsList.Add(lamp); } var groundList = new List <Ground>(); groundList.Add(new Ground(new Position(Dimensions.Canvas.Width - ((Dimensions.Element.Width / 4) + Dimensions.Element.Width * 2), 0))); foreach (var ground in groundList) { ground.Position.Height = (Dimensions.Canvas.Height / 2) - (groundList.Count * ground.Size.Height / 2) - (Dimensions.Element.Height / 4) + (groundList.IndexOf(ground) * ground.Size.Height); ElementsList.Add(ground); } AsstesList.AddRange(ElementsList); AsstesList.AddRange(LampsList); AsstesList.AddRange(GatesList); }
void PopElement() { if (nowWaitTime < -1 && ElementsList.Count != 0 && !IsExistSideElement()) { nowWaitTime = 0F; switch (scriptKind) { case SCRIPTTYPE.GOTOBLUE: GoToFlag(SCRIPTTYPE.FLAGBLUE); nowWaitTime = 3F; // slow.. break; case SCRIPTTYPE.GOTOGREEN: GoToFlag(SCRIPTTYPE.FLAGGREEN); nowWaitTime = 3F; // slow.. break; case SCRIPTTYPE.PRINT: // Opeariton of PRINTs ... Print(); PutElement(ElementsList[0], putRight); break; case SCRIPTTYPE.SUBSTITUTE: GameObject clone = Instantiate(SaucerList [0].onElement) as GameObject; clone.transform.parent = GameObject.Find("Elements").transform; PutElement(clone, putRight); break; case SCRIPTTYPE.EQUAL: case SCRIPTTYPE.GREATER: case SCRIPTTYPE.LESS: PutElementUp(ElementsList[0], flag1); break; default: PutElement(ElementsList[0], putRight); break; } animator.SetTrigger("inElement"); audioSource.PlayOneShot(outputSE); ElementsList.RemoveAt(0); CheckDestroyBox(); } }
public void AssertSpecificRow() { // You can get a specific row using the GetRow method by the index of the row. var firstRow = Table.GetRow(0); // You can get the index of a given row through the Index property. Assert.AreEqual(0, firstRow.Index); // You can get the HTML through the InnerHtml property. Assert.IsTrue(firstRow.InnerHtml.Contains("</td>")); // If you only need to assert the inner HTML you can use the built-in BELLATRIX Validate methods. firstRow.ValidateInnerHtmlContains("</td>"); // There are many ways to get a specific cell through the indexer and the GetCell methods. var firstCell = Table.GetRow(0).GetCell(0); // You can again use directly the built-in BELLATRIX Validate methods. firstCell.ValidateInnerTextIs("Smith"); // You can get a cell by header name var secondCell = firstRow.GetCell("Email"); secondCell.ValidateInnerTextIs("*****@*****.**"); // You can get all row cells through the GetCells method. IEnumerable <TableCell> cells = firstRow.GetCells(); Assert.AreEqual(6, cells.Count()); // You can get the cells matching a condition. ElementsList <TableCell> matchingCells = firstRow.GetCells(cell => cell.InnerText.ToLower().Contains("smith")); Assert.AreEqual(3, matchingCells.Count()); // You can get the first cell matching a condition through the GetFirstOrDefaultCell method. var matchingCell = firstRow.GetFirstOrDefaultCell(cell => cell.InnerText.ToLower().Contains("smith")); matchingCell.ValidateInnerTextIs("Smith"); // You can convert a row to an instance of a specific class through the GetItem method. Assert.AreEqual("*****@*****.**", firstRow.GetItem <User>().Email); // You can compare a row to an instance of a specific class. // The row is internally converted to the type of the expected object. firstRow.AssertRow(_expectedUsers[0]); }
/// <summary> /// Adds element to the collection /// </summary> /// <param name="matrix">Element for adding</param> public override void Add(Matrix <T> matrix) { if (matrix == null || matrix.Count == 0) { throw new ArgumentNullException("The argument is null"); } if (ElementsList.Count > 0) { if (!CheckMatrix(ElementsList.Last(), matrix)) { string message = "Every matrix in container should have the same amount of positions."; throw new ArgumentException(message); } } base.AddElement(matrix); }
//convert the dictionary to a list of type "ElementsList" public ElementsList ToList() { var list = new List <DictionaryElement>(); foreach (var item in MyDictionary) { var temp = new DictionaryElement(); temp.Word = item.Key; temp.Definition = item.Value; list.Add(temp); } var elementsList = new ElementsList(); elementsList.Words = list; return(elementsList); }
// read data from file, if file exists, else create it public ElementsList ReadData() { try { if (File.Exists(fileName)) { string contents = File.ReadAllText(fileName); DefaultWords = JsonUtility.FromJson <ElementsList>(contents); } else { DefaultWords = new ElementsList(); DefaultWords.Words = new List <DictionaryElement>(); DefaultWords.Words.Add(new DictionaryElement() { Word = "table", Definition = "table definition" }); DefaultWords.Words.Add(new DictionaryElement() { Word = "chair", Definition = "chair definition" }); DefaultWords.Words.Add(new DictionaryElement() { Word = "problem", Definition = "A thing that is difficult to achieve" }); DefaultWords.Words.Add(new DictionaryElement() { Word = "abstract", Definition = "abstract definition" }); DefaultWords.Words.Add(new DictionaryElement() { Word = "book", Definition = " A literary composition" }); SaveData(); } } catch (System.Exception) { DefaultWords = new ElementsList(); } return(DefaultWords); }
public void AssertSpecificRow() { var firstRow = TestGrid.GetRow(0); // You can get the index of a given row through the Index property. Assert.AreEqual(0, firstRow.Index); // You can get the html through the InnerHtml property. Assert.IsTrue(firstRow.InnerHtml.Contains("</td>")); firstRow.ValidateInnerHtmlContains("</td>"); // There are many ways to get a specific cell through the indexer and the GetCell methods. var firstCell = firstRow.GetCell("Order"); firstCell.As <TextField>().ValidateValueIs("0"); var secondCell = firstRow[1]; secondCell = firstRow.GetCell(1); secondCell.ValidateInnerTextIs("John"); // You can get all row cells through the GetCells method. IEnumerable <GridCell> cells = firstRow.GetCells(); Assert.AreEqual(6, cells.Count()); // You can get the cells matching a condition. Also, they will be returned as elements of a type of your choice. ElementsList <TableCell> textFields = firstRow.GetCells <TableCell>(cell => cell.InnerText.StartsWith("John") || cell.InnerText.StartsWith("john")); Assert.AreEqual(2, textFields.Count()); // You can get the first cell matching a condition through the GetFirstOrDefaultCell method. var firstInputCell = firstRow.GetFirstOrDefaultCell <TextField>(cell => cell.TagName == "input"); firstInputCell.ValidateValueIs("0"); // You can convert a row to an instance of a specific class through the GetItem method. Assert.AreEqual("John Doe", $"{firstRow.GetItem<Employee>().FirstName} {firstRow.GetItem<Employee>().LastName}"); // You can compare a row to an instance of a specific class. The row is internally converted to the type of the expected object. firstRow.AssertRow(_expectedItems[0]); }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Element") || collision.gameObject.CompareTag("Card")) { if (IsNoAbsorbScriptType()) { ElemetsBehavior eleBhv = collision.GetComponent <ElemetsBehavior>(); if (eleBhv.existAimPos) { return; } eleBhv.HideElement(); ElementsList.Add(collision.gameObject); // These is executed soon. if (scriptKind == SCRIPTTYPE.ADD || scriptKind == SCRIPTTYPE.SUBSTITUTE || scriptKind == SCRIPTTYPE.BLACKHOLE) { nowWaitTime = 0; } else { nowWaitTime = weitTime; } addElements = true; execDecision = false; animator.SetTrigger("inElement"); audioSource.PlayOneShot(absorbSE); } else { NoAbsorbBehavior(); } } }
public void AssertCells() { // As a shortcut, you can iterate over all table cells through the ForEachCell method. Table.ForEachCell(cell => Assert.AreEqual("14px", cell.GetCssValue("font-size"))); // You can get a particular cell as BELLATRIX element mentioning the column header and row number. Table.GetCell("First Name", 1).ValidateInnerTextIs("Frank"); // You can get a particular cell as BELLATRIX element mentioning the row and column number. Table.GetCell(1, 2).ValidateInnerTextIs("Jason"); // You can get a particular cell by header expression and row number. Table.GetCell <User>(cell => cell.Email, 1).ValidateInnerTextIs("*****@*****.**"); // You can get particular cells by a selector. ElementsList <TableCell> cells = Table.GetCells(cell => cell.InnerText.ToLower().StartsWith('j')); Assert.AreEqual(4, cells.Count()); // As a shortcut, you can get the first cell matching a given condition through the GetFirstOrDefaultCell method. var matchingCell = Table.GetFirstOrDefaultCell(cell => cell.InnerText.ToLower().StartsWith('j')); matchingCell.ValidateInnerTextIs("John"); }
void Awake() { DefaultWords = new ElementsList(); ReadData(); }