Esempio n. 1
0
        public IFakeJoinedRow JoinToNew(IFakeJoinedRow row)
        {
            IFakeJoinedRow newRow = new FakeJoinedRow();

            newRow.JoinRow(this);
            newRow.JoinRow(row);
            return(newRow);
        }
Esempio n. 2
0
 public void JoinRow(IFakeJoinedRow row)
 {
     row.ForEach(element =>
     {
         if (!this.Values.ContainsKey(element.Key))
         {
             this.Values.Add(element.Key, element.Value);
         }
     });
 }
Esempio n. 3
0
        /// <summary>
        /// Returns <see cref="IDictionary{TKey, TValue}"/> which contains <see cref="KeyValuePair{TKey, TValue}"/>s
        /// where Key is checked <see cref="IFakeTable"/> and
        /// Value is a <see cref="IEnumerable{T}"/> which contains <see cref="IFakeJoinedRow"/>s
        /// which were made by adding <see cref="IFakeRow"/> to this <see cref="IFakeJoinedRow"/> by given Column Name.
        /// This is in form of <see cref="IEnumerable{T}"/> because multiple <see cref="IFakeRow"/>s could have value in specified <see cref="IFakeColumn"/> equal with this <see cref="IFakeJoinedRow"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="tables"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        public static IDictionary <IFakeTable, List <IFakeJoinedRow> > JoinRow(this IFakeJoinedRow source, IEnumerable <IFakeTable> tables, string columnName)
        {
            IDictionary <IFakeTable, List <IFakeJoinedRow> > result = new Dictionary <IFakeTable, List <IFakeJoinedRow> >();

            tables.ForEach(table =>
            {
                result.Add(table, JoinRow(source, table, columnName));
            });

            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns <see cref="List{T}"/> which contains <see cref="IFakeJoinedRow"/>s
        /// which were made by adding <see cref="IFakeRow"/> to this <see cref="IFakeJoinedRow"/>.
        /// This is in form of <see cref="List{T}"/> because multiple <see cref="IFakeRow"/>s could have value in specified <see cref="IFakeColumn"/> equal with this <see cref="IFakeJoinedRow"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="table"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        public static List <IFakeJoinedRow> JoinRow(this IFakeJoinedRow source, IFakeTable table, string columnName)
        {
            List <IFakeJoinedRow> list = new List <IFakeJoinedRow>();

            table.Rows.ForEach(row =>
            {
                if (source.CanJoinRow(row, columnName))
                {
                    list.Add(source.JoinToNew(row.ToJoinedRow()));
                }
            });

            return(list);
        }
Esempio n. 5
0
        public bool CanJoinRow(IFakeJoinedRow row, string columnName)
        {
            try
            {
                // Try to get value and if value does not exist , exception will be thrown.
                // It also means that given Row doesn't contains column with specified name.
                var x = row.Values[columnName];

                if (this.Values.ContainsKey(columnName))
                {
                    return(true);
                }
                return(false);
            }
            catch (KeyNotFoundException)
            {
                throw new KeyNotFoundException(string.Format("Give column ({0}) does not exist in given Row.", columnName));
            }
        }