コード例 #1
0
        private Func<int, object> GetValidRowFetcherDelegate(Table table, IBindingType typeToConvertTo, CultureInfo cultureInfo)
        {
            if (table.RowCount == 0)
                return x => null;

            var pivotTable = new PivotTable(table);
            if (stepArgumentTypeConverter.CanConvert(pivotTable.GetInstanceTable(0), typeToConvertTo, cultureInfo))
                return x => pivotTable.GetInstanceTable(x);

            if (table.Header.Count == 1 &&
                stepArgumentTypeConverter.CanConvert(table.Rows[0][0], typeToConvertTo, cultureInfo))
                return x => table.Rows[x][0];

            return null;
        }
コード例 #2
0
        private IEnumerable <int> GetListOfExpectedItemsThatCouldNotBeFound(IEnumerable <T> set)
        {
            var actualItems = GetTheActualItems(set);

            var listOfMissingItems = new List <int>();

            var pivotTable = new PivotTable(table);

            for (var index = 0; index < table.Rows.Count(); index++)
            {
                var instanceTable = pivotTable.GetInstanceTable(index);

                var matchIndex = GetTheIndexOfTheMatchingItem(instanceTable, actualItems);

                if (matchIndex == MatchNotFound)
                {
                    listOfMissingItems.Add(index + 1);
                }
                else
                {
                    RemoveFromActualItemsSoItWillNotBeCheckedAgain(actualItems, matchIndex);
                }
            }
            return(listOfMissingItems);
        }
コード例 #3
0
ファイル: SetComparer.cs プロジェクト: zhengbingjie/SpecFlow
        private IEnumerable <int> GetListOfExpectedItemsThatCouldNotBeFoundOrderInsensitive(IEnumerable <T> set)
        {
            var actualItems = GetTheActualItems(set);

            var listOfMissingItems = new List <int>();

            var pivotTable = new PivotTable(table);

            for (var index = 0; index < table.Rows.Count(); index++)
            {
                var instanceTable = pivotTable.GetInstanceTable(index);

                var matchIndex = GetTheIndexOfTheMatchingItem(instanceTable, actualItems);

                if (matchIndex == MatchNotFound)
                {
                    listOfMissingItems.Add(index + 1);
                }
                else
                {
                    RemoveFromActualItemsSoItWillNotBeCheckedAgain(actualItems, matchIndex);
                }
            }

            extraOrNonMatchingActualItems = actualItems.Select(i => new TableDifferenceItem <T>(i)).ToList();
            return(listOfMissingItems);
        }
コード例 #4
0
ファイル: SetComparer.cs プロジェクト: abhishekch85/SpecFlow
        private IEnumerable <int> GetListOfExpectedItemsThatCouldNotBeFoundOrderSensitive(IEnumerable <T> set)
        {
            var actualItems = GetTheActualItems(set);

            var listOfMissingItems = new List <int>();

            var pivotTable = new PivotTable(table);

            for (var index = 0; index < Math.Min(actualItems.Count, table.Rows.Count()); index++)
            {
                var instanceTable = pivotTable.GetInstanceTable(index);
                if (!ThisItemIsAMatch(instanceTable, actualItems[index]))
                {
                    listOfMissingItems.Add(index + 1);
                }
            }

            extraOrNonMatchingActualItems =
                listOfMissingItems.Select(index => new TableDifferenceItem <T>(actualItems[index - 1], index)).Concat(
                    actualItems.Skip(table.RowCount).Select(i => new TableDifferenceItem <T>(i)))
                .ToList();

            var extraTableItems = table.Rows.Count() - actualItems.Count;

            if (extraTableItems > 0)
            {
                for (var index = actualItems.Count; index < table.Rows.Count(); index++)
                {
                    listOfMissingItems.Add(index + 1);
                }
            }

            return(listOfMissingItems);
        }
コード例 #5
0
        public static IEnumerable <T> CreateSet <T>(this Table table)
        {
            var pivotTable = new PivotTable(table);

            var list = new List <T>();

            for (var index = 0; index < table.Rows.Count(); index++)
            {
                var instance = pivotTable.GetInstanceTable(index).CreateInstance <T>();
                list.Add(instance);
            }

            return(list);
        }
コード例 #6
0
        public static IEnumerable <T> CreateSet <T>(this Table table, Func <T> methodToCreateEachInstance)
        {
            var list = new List <T>();

            var pivotTable = new PivotTable(table);

            for (var index = 0; index < table.Rows.Count(); index++)
            {
                var instance = methodToCreateEachInstance();
                pivotTable.GetInstanceTable(index).FillInstance(instance);
                list.Add(instance);
            }

            return(list);
        }
コード例 #7
0
        public static IEnumerable <T> CreateSet <T>(this Table table, Func <TableRow, T> methodToCreateEachInstance, InstanceCreationOptions creationOptions)
        {
            int count = table.Rows.Count;
            var list  = new List <T>(count);

            var pivotTable = new PivotTable(table);

            for (var index = 0; index < count; index++)
            {
                var row      = table.Rows[index];
                var instance = methodToCreateEachInstance(row);
                pivotTable.GetInstanceTable(index).FillInstance(instance, creationOptions);
                list.Add(instance);
            }

            return(list);
        }
コード例 #8
0
        public static IEnumerable <T> CreateSet <T>(this Table table, InstanceCreationOptions creationOptions)
        {
            int count = table.Rows.Count;

            var list = new List <T>(count);


            var pivotTable = new PivotTable(table);

            for (var index = 0; index < count; index++)
            {
                var instance = pivotTable.GetInstanceTable(index).CreateInstance <T>(creationOptions);
                list.Add(instance);
            }

            return(list);
        }
コード例 #9
0
ファイル: PivotTableTests.cs プロジェクト: BEllis/SpecFlow
 private static Table PivotThisTable(Table setTable, int index)
 {
     var pivotTable = new PivotTable(setTable);
     return pivotTable.GetInstanceTable(index);
 }