private static IReadOnlyCollection <RowMatchingResult> ListDataMismatches <TRowType>(
            TableRows expectedRows,
            IEnumerable <TRowType> actualRows,
            Func <TRowType, string, object> getCellValue)
        {
            var firstColumnName = expectedRows.First().Keys.First();

            var expectedRowsWithIndexAndKey = expectedRows.Select((row, index) => new { row, index, key = row[0] }).AsImmutable();
            var actualRowsWithKey           = actualRows.Select((row, index) => new { row, index, key = getCellValue(row, firstColumnName).ToString() }).AsImmutable();

            var mismatchedAndMissingRows =
                from expectedRow in expectedRowsWithIndexAndKey
                join actualRow in actualRowsWithKey on expectedRow.key equals actualRow.key into matchedActualRows
                from matchedActualRow in matchedActualRows.DefaultIfEmpty()
                let rowMatchingResult = matchedActualRow != null
                    ? MatchRows(expectedRow.row, matchedActualRow.row, expectedRow.index, getCellValue)
                    : new MissingRow(expectedRow.key, expectedRow.index)
                                            where rowMatchingResult != null
                                        select rowMatchingResult;

            var unnecessaryRows =
                from actualRow in actualRowsWithKey
                where expectedRowsWithIndexAndKey.All(row => row.key != actualRow.key)
                select new UnnecessaryRow(actualRow.key);

            return(mismatchedAndMissingRows.Concat(unnecessaryRows).AsImmutable());
        }
Example #2
0
 public Table()
     : base()
 {
     Style = new TableStyle();
     Rows = new TableRows();
     Rows.ItemsInserted += OnRowsInserted;
 }
Example #3
0
        public static IEnumerable<MatchInformation> ConvertToMatchInformationList(TableRows row)
        {
            var qry = row.Select(it => new MatchInformation
            {
                Id = it.ConvertToInt("Id"),
                LeagueName = it.GetString("LeagueName"),
                Status = it.GetString("Status"),
                BeginDate = it.ConvertToDateTime("BeginDate"),
                CompletedDate = it.ConvertToNullableDateTime("CompletedDate"),
                StartedDate = it.ConvertToNullableDateTime("StartedDate"),
                CalculatedDate = it.ConvertToNullableDateTime("CalculatedDate"),
                TeamAway = new TeamInformation
                {
                    Id = it.ConvertToInt("TeamAway.Id"),
                    Name = it.GetString("TeamAway.Name"),
                    CurrentScore = it.ConvertToInt("TeamAway.CurrentScore"),
                    IsSelected = it.ConvertToBoolean("TeamAway.IsSelected"),
                    CurrentPredictionPoints = it.ConvertToInt("TeamAway.CurrentPredictionPoints"),
                    WinningPredictionPoints = it.ConvertToInt("TeamAway.WinningPredictionPoints")
                },
                TeamHome = new TeamInformation
                {
                    Id = it.ConvertToInt("TeamHome.Id"),
                    Name = it.GetString("TeamHome.Name"),
                    CurrentScore = it.ConvertToInt("TeamHome.CurrentScore"),
                    IsSelected = it.ConvertToBoolean("TeamHome.IsSelected"),
                    CurrentPredictionPoints = it.ConvertToInt("TeamHome.CurrentPredictionPoints"),
                    WinningPredictionPoints = it.ConvertToInt("TeamHome.WinningPredictionPoints")
                },
            }).ToList();

            return qry;
        }
        private IOperation CreateAddingToTableOperation(params string[] row)
        {
            var tempIsTableVisibile = IsTableVisible;
            var newRow = new TableRow(row);

            System.Action redo = () =>
            {
                Execute.OnUIThread(() =>
                {
                    TableRows.Add(newRow);
                    NotifyOfPropertyChange(() => TableRows);
                });
                ShowTable();
            };
            System.Action undo = () =>
            {
                Execute.OnUIThread(() =>
                {
                    TableRows.RemoveLast(newRow);
                    NotifyOfPropertyChange(() => TableRows);
                });
                if (tempIsTableVisibile)
                {
                    ShowTable();
                }
                else
                {
                    HideTable();
                }
            };

            return(new SimpleOperation(redo, undo));
        }
Example #5
0
        public void ThenFirstCardIsSelectedByDefaultAndSelectingEachCardDisplaysDistributionDetail()
        {
            //Get original set of parameters
            Table     table    = ScenarioContext.Current.Get <Table>("Parameters Table");
            TableRows expected = table.Rows;
            int       position = 1;

            //Verify that all cards selection results in details displaying bellow
            foreach (TableRow expCard in expected)
            {
                if (position == 1)
                {
                    //First card should be selected by default
                    distributionTab.IsCardSelectedByPosition(1).Should().BeTrue("Card styles applied to selected card");
                }
                else
                {
                    //For other cards select and then verify
                    distributionTab.SelectSummaryCardByPosition(position);
                    distributionTab.IsCardSelectedByPosition(position).Should().BeTrue("Card styles applied to selected card");
                }

                this.verifyDistributionDetails(expCard);

                position++;
            }

            //Verify going back to 1st card shows details correctly
            TableRow expFirst = expected[0];

            distributionTab.SelectSummaryCardByPosition(1);
            distributionTab.IsCardSelectedByPosition(1).Should().BeTrue("Card styles applied to selected card");
            this.verifyDistributionDetails(expFirst);
        }
Example #6
0
        public List <ContactData> GetContactsList()
        {
            {
                List <ContactData> list = new List <ContactData>();
                TableRows          rows = GetContactsDataFromTable();
                for (int i = 0; i < rows.Count; i++)
                {
                    string firstname = rows[i].Cells[0].Value.ToString().Contains("не определено") ?
                                       null : rows[i].Cells[0].Value.ToString();
                    string lastname = rows[i].Cells[1].Value.ToString().Contains("не определено") ?
                                      null : rows[i].Cells[1].Value.ToString();
                    string company = rows[i].Cells[2].Value.ToString().Contains("не определено") ?
                                     null : rows[i].Cells[2].Value.ToString();
                    string city = rows[i].Cells[3].Value.ToString().Contains("не определено") ?
                                  null : rows[i].Cells[3].Value.ToString();
                    string address = rows[i].Cells[4].Value.ToString().Contains("не определено") ?
                                     null : rows[i].Cells[4].Value.ToString();

                    list.Add(new ContactData
                    {
                        Firstname = firstname,
                        Lastname  = lastname,
                        Company   = company,
                        City      = city,
                        Address   = address
                    });
                }
                return(list);
            }
        }
Example #7
0
        private TableCell GetCell(int index)
        {
            TableRows  rows  = table.Rows;
            TableCells cells = rows[index - 1].Cells;

            return(cells[0]);
        }
Example #8
0
        public void TableRows()
        {
            table.LogStructure();
            TableRows tableRows = table.Rows;

            Assert.AreEqual(true, tableRows.Count >= 13, tableRows.Count.ToString());
        }
        private IOperation CreateRowRemovingFromTableOperation(string[] row)
        {
            TableRow tempDeletedRow = new TableRow(row);

            System.Action redo = () =>
            {
                Execute.OnUIThread(() =>
                {
                    if (!TableRows.Remove(new TableRow(row)))
                    {
                        tempDeletedRow = null;
                        return;
                    }
                    NotifyOfPropertyChange(() => TableRows);
                });
            };
            System.Action undo = () =>
            {
                Execute.OnUIThread(() =>
                {
                    if (tempDeletedRow != null)
                    {
                        TableRows.Add(tempDeletedRow);
                        NotifyOfPropertyChange(() => TableRows);
                    }
                });
            };

            return(new SimpleOperation(redo, undo));
        }
        public void ThenISeeAssetsSummaryCardsAndAllValuesAreCorrect(Table table)
        {
            ScenarioContext.Current.Add("Parameters Table", table);

            TableRows expected = table.Rows;
            List <AssetSummaryItemData> summaryCards = assetsTab.GetAssetsSummaryItems();

            //check each item in given order, positions should match
            for (int i = 0; i < expected.Count; i++)
            {
                //expected values in this position
                TableRow row               = expected[i];
                string   expTitle          = row["Title"] + " (" + row["Count"] + ")";
                string   expRemainingValue = row["Remaining Value"];
                string   expPetitionValue  = row["Petition Value"];
                string   expExemptions     = row["Exemptions"];
                string   expSales          = row["Sales"];

                //actual values in this position
                AssetSummaryItemData item = summaryCards[i];

                //verifications
                item.Title.Should().Be(expTitle, "Tile header text is " + expTitle + "for Summary Item #" + i);
                item.RemainingValue.Should().Be(expRemainingValue, "Card " + expTitle + " displays Remaining Value = " + expRemainingValue);
                item.PetitionValue.Should().Be(expPetitionValue, "Card " + expTitle + " displays Petition Value = " + expPetitionValue);
                item.Exemptions.Should().Be(expExemptions, "Card " + expTitle + " displays Exemptions = " + expExemptions);
                item.Sales.Should().Be(expSales, "Card " + expTitle + " displays Sales = " + expSales);
            }
        }
Example #11
0
        public void SetUp()
        {
            TableRows rows = table.Rows;

            row = rows[0];
            row.Cells[0].Value = "Imran";
        }
Example #12
0
        void TableRows()
        {
            table.LogStructure();
            TableRows tableRows = table.Rows;

            Assert.True(tableRows.Count >= 13, tableRows.Count.ToString());
        }
Example #13
0
        //Groups: The Add Rows operation adds Rows to a Table in a Dataset in a Group.
        //POST https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables/{table_name}/rows
        //Add Rows operation: https://msdn.microsoft.com/en-US/library/mt203561.aspx
        static void AddRows(string groupId, string datasetId, string tableName)
        {
            //In a production application, use more specific exception handling.
            try
            {
                var datasetClient = new DatasetsClient(pbi);
                //Create a list of Product
                List <Product> products = new List <Product>
                {
                    new Product {
                        ProductID = 1, Name = "Adjustable Race", Category = "Components", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30)
                    },
                    new Product {
                        ProductID = 2, Name = "LL Crankarm", Category = "Components", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30)
                    },
                    new Product {
                        ProductID = 3, Name = "HL Mountain Frame - Silver", Category = "Bikes", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30)
                    },
                };
                var tableRows = new TableRows <Product>();
                tableRows.rows = products;

                //POST request using the json from a list of Product
                //NOTE: Posting rows to a model that is not created through the Power BI API is not currently supported.
                //      Please create a dataset by posting it through the API following the instructions on http://dev.powerbi.com.
                datasetClient.AddRows <Product>(groupId, datasetId, tableName, tableRows);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        private void ThenISeeAllClaimCategoriesDisplayCorrectly(Table table)
        {
            TableRows expectedClasses = table.Rows;

            DistributionForm newDistribution = ScenarioContext.Current.Get <DistributionForm>("New Distribution Form");
            IEnumerator <DistributionClaimCategoryData> actualCategories = newDistribution.GetFirstNCategories(expectedClasses.Count).GetEnumerator();

            actualCategories.MoveNext();

            foreach (TableRow expCategoryData in expectedClasses)
            {
                string expClassName = expCategoryData["Claim Category"];
                string expCount     = expCategoryData["Count"];
                bool   expSelected  = Convert.ToBoolean(expCategoryData["Selected"]);
                string expBalance   = expCategoryData["Balance"];
                string expReserved  = expCategoryData["Reserved"];

                DistributionClaimCategoryData categoryData = actualCategories.Current;
                categoryData.Selected.Should().Be(expSelected, "Claim Class '" + expClassName + "' selected is correct");
                categoryData.Name.Should().Be(expClassName + " (" + expCount + ")", "Claim Class '" + expClassName + "' name is correct");
                categoryData.BalanceLabel.Should().Be("BALANCE", "Claim Class '" + expClassName + "' balance label is correct");
                categoryData.BalanceValue.Should().Be(expBalance, "Claim Class '" + expClassName + "' balance value is correct");
                categoryData.Reserved.Should().Be(expReserved + " Reserved");

                actualCategories.MoveNext();
            }
        }
Example #15
0
 //Copy all rows from source to target via clone
 public static void CopyRows(TableRows source, TableRows target)
 {
     foreach (TableRow row in source)
     {
         target.Add((TableRow)row.Clone());
     }
 }
        /// <summary>
        /// Command Rank.
        /// </summary>
        public double CommandRank(string name)
        {
            var rows = TableRows.ToList();
            var row  = rows.First(x => x.FindElement(By.CssSelector(".team_name_span a")).Text.Contains(name));
            var rank = row.FindElement(By.CssSelector(".rank")).Text.Trim('.');

            return(Double.Parse(rank));
        }
Example #17
0
        public void FindAllTest()
        {
            TableRows rows = table.Rows;

            rows[1].Cells[0].Value = "Imran";
            Assert.AreEqual("Imran", table.FindAll("Name", "Imran")[0].Cells[0].Value);
            Assert.AreEqual("Imran", table.FindAll("Name", "Imran")[1].Cells[0].Value);
        }
Example #18
0
        public void GetMultipleRowsTest()
        {
            TableRows rows = table.Rows;

            rows[1].Cells[0].Value = "Imran";
            Assert.AreEqual("Imran", rows.GetMultipleRows("Name", "Imran")[0].Cells[0].Value);
            Assert.AreEqual("Imran", rows.GetMultipleRows("Name", "Imran")[1].Cells[0].Value);
        }
Example #19
0
 public TableGroup(TableGroup prototype) : base(prototype)
 {
     _expanded = prototype.Expanded;
     Rows      = new TableRows();
     Groups    = new TableGroups();
     Table.CopyRows(prototype.Rows, Rows);
     Table.CopyGroups(prototype.Groups, Groups);
 }
        /// <summary>
        /// Games Number.
        /// </summary>
        public double DifferenceScoredAndMissedGoals(string name)
        {
            var rows   = TableRows.ToList();
            var row    = rows.First(x => x.FindElement(By.CssSelector(".team_name_span a")).Text.Equals(name));
            var points = row.FindElements(By.CssSelector(".goals"))[0].Text.Split(':');

            return(Double.Parse(points[0]) - Double.Parse(points[1]));
        }
Example #21
0
 public void GivenIHaveTheFollowingRepositories(Table table)
 {
     tableRows = table.Rows;
     foreach (var row in tableRows)
     {
         var response = client.GetRepo(row[0], row[1]);
         response.EnsureSuccessStatusCode();
     }
 }
Example #22
0
 /// <summary>
 /// Converts a DbDataReader to an EFTableRows
 /// </summary>
 public DataReaderLoader(DbDataReader dbReader)
 {
     _dbReader  = dbReader;
     _tableRows = new TableRows(_dbReader)
     {
         FieldCount        = _dbReader.FieldCount,
         VisibleFieldCount = _dbReader.VisibleFieldCount
     };
 }
        protected override void ExecuteTestRun(WindowsFramework framework)
        {
            SelectDataGridTab();
            table = MainWindow.Get<Table>("DataGrid");
            rows = table.Rows;

            RunTest(RowData);
            RunTest(GetRowAfterSortingOnAColumn);
            RunTest(Select);
        }
Example #24
0
        protected override void ExecuteTestRun(WindowsFramework framework)
        {
            SelectDataGridTab();
            table = MainWindow.Get <Table>("DataGrid");
            rows  = table.Rows;

            RunTest(RowData);
            RunTest(GetRowAfterSortingOnAColumn);
            RunTest(Select);
        }
Example #25
0
        private void RenderTableRows(Table table, Graphics graphics, Render render, TableRows rows, ref float iHeight)
        {
            foreach (TableRow tableRow in rows)
            {
                IFormsRenderer renderer = render.GetRenderer(tableRow);
                renderer.RenderElement(tableRow, graphics, render);

                iHeight += table.RowHeight;
            }
        }
Example #26
0
        public int GetContactCount()
        {
            Window mainWindow = manager.MainWindow;

            Table     table     = mainWindow.Get <Table>("uxAddressGrid");
            TableRows tableRows = table.Rows;
            int       count     = tableRows.Count();

            return(count);
        }
        public List <ContactData> GetContactsList()
        {
            List <ContactData> list      = new List <ContactData>();
            TableRows          tableRows = manager.MainWindow.Get <Table>("uxAddressGrid").Rows;

            foreach (TableRow row in tableRows)
            {
                list.Add(new ContactData(row.Cells[1].Value.ToString(), row.Cells[0].Value.ToString()));
            }
            return(list);
        }
        public void RemoveContactAtIndex(int index)
        {
            TableRows rows = manager.MainWindow.Get <Table>("uxAddressGrid").Rows;

            rows[index].Click();
            manager.MainWindow.Get <Button>("uxDeleteAddressButton").Click();
            Window dialogue = manager.MainWindow.ModalWindow("Question");
            Button btn      = (Button)dialogue.Get(SearchCriteria.ByText("Yes"));

            btn.Click();
        }
Example #29
0
        public void SelectRowNotVisibleInitially()
        {
            TableRows rows = table.Rows;
            TableRow  row  = rows[rows.Count - 1];

            row.Select();
            Assert.AreEqual(false, row.IsOffScreen);
            row = rows[0];
            Assert.AreEqual(true, row.IsOffScreen);
            row.Select();
            Assert.AreEqual(false, row.IsOffScreen);
        }
Example #30
0
        private void SortTableRows()
        {
            SortedTableRows.ReplaceRange(TableRows.OrderBy(p => p.PartitionKey));

            if (SortedTableRows.Count > 0)
            {
                NoTableRowsFound = false;
            }
            else
            {
                NoTableRowsFound = true;
            }
        }
Example #31
0
        public void Remove(int index)
        {
            Window mainWindow = manager.MainWindow;

            Table     table     = mainWindow.Get <Table>("uxAddressGrid");
            TableRows tableRows = table.Rows;

            tableRows[0].Select();
            mainWindow.Get <Button>("uxDeleteAddressButton").Click();
            Window questionWindow = mainWindow.ModalWindow("Question");

            questionWindow.Get <Button>(SearchCriteria.ByText("Yes")).Click();
        }
        public void ThenISeeThisCasesOnTheResultList(Table table)
        {
            TableRows     expectedResults = table.Rows;
            List <string> actualResults   = dashboardPage.UniversalSearch.ResultsList;

            int position = 0;

            foreach (TableRow expCase  in expectedResults)
            {
                string expectedCase = expCase["Case Result"];
                actualResults[position].Should().Be(expectedCase, "Expected Case '" + expectedCase + "' is part of Results for the Search");
                position++;
            }
        }
        protected override void ExecuteTestRun(WindowsFramework framework)
        {
            SelectDataGridTab();
            table = MainWindow.Get <Table>("DataGrid");
            TableRows rows = table.Rows;

            row = rows[0];

            RunTest(SetTextCellValue);
            RunTest(GetEmptyValue);
            RunTest(SetCheckBoxCellValue);
            RunTest(SetComboBoxCellValue);
            RunTest(TextOnButtonCell);
            RunTest(Click);
        }
Example #34
0
 protected override void TestFixtureSetUp()
 {
     table = window.Get<Table>("people");
     rows = table.Rows;
 }
Example #35
0
 public void Setup()
 {
     SelectDataGridTab();
     table = MainWindow.Get<UIItems.TableItems.Table>("DataGrid");
     rows = table.Rows;
 }
Example #36
0
        private async static Task GenerateData()
        {
            var dataClient = new DatasetsClient(pbi);
            var created = (await dataClient.List()).value.First(ds => ds.name == "resourceManager");
            var tables = await dataClient.ListTables(created.id);

            var dataRows = new TableRows<resourceMeasures>();

            for (int i = 0; i < 1000; i++)
            {
                dataRows.rows.Add(new resourceMeasures()
                {
                    Id = Guid.NewGuid().ToString("n"),
                    InServiceDate = DateTime.Now.AddYears(-4),
                    IsRunning = true,
                    LastMeasure = DateTime.Now,
                    Name = "Engine" + i.ToString(),
                    RPM = 6000,
                    Temperature = 431.6
                });
            }
            await dataClient.ClearRows(created.id, tables.value.First().name);
            await dataClient.AddRows(created.id, tables.value.First().name, dataRows);
            while (true)
            {
                Console.Write(".");
                foreach (var row in dataRows.rows)
                {
                    row.RPM = (int)(6000 * Math.Sin(Math.PI * (DateTime.Now.Second / 59D)));
                    row.Temperature += new Random((int)DateTime.Now.Ticks).Next(-5, 5);
                    row.LastMeasure = DateTime.Now;
                    row.IsRunning = row.RPM > 1;
                    Thread.Sleep(1);
                }

                await dataClient.AddRows(created.id, tables.value.First().name, dataRows);
            }
            await dataClient.ClearRows(created.id, tables.value.First().name);
        }
Example #37
0
 public virtual void Refresh()
 {
     rows = null;
 }
Example #38
0
        //Groups: The Add Rows operation adds Rows to a Table in a Dataset in a Group.
        //POST https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables/{table_name}/rows
        //Add Rows operation: https://msdn.microsoft.com/en-US/library/mt203561.aspx
        static void AddRows(string groupId, string datasetId, string tableName)
        {
            //In a production application, use more specific exception handling. 
            try
            {
                var datasetClient = new DatasetsClient(pbi);
                //Create a list of Product
                List<Product> products = new List<Product>
                {
                    new Product{ProductID = 1, Name="Adjustable Race", Category="Components", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30)},
                    new Product{ProductID = 2, Name="LL Crankarm", Category="Components", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30)},
                    new Product{ProductID = 3, Name="HL Mountain Frame - Silver", Category="Bikes", IsCompete = true, ManufacturedOn = new DateTime(2014, 7, 30)},
                };
                var tableRows = new TableRows<Product>();
                tableRows.rows = products;

                //POST request using the json from a list of Product
                //NOTE: Posting rows to a model that is not created through the Power BI API is not currently supported. 
                //      Please create a dataset by posting it through the API following the instructions on http://dev.powerbi.com.
                datasetClient.AddRows<Product>(groupId, datasetId, tableName, tableRows);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }