Example #1
0
        /// <summary>
        /// Compares the data to another result and returns the rows that differ
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public IEnumerable<Tuple<object[], object[]>> GetDifferences( QueryData obj )
        {
            if ( obj == null )
                throw new ArgumentNullException ( "obj" );

            var differences = from rows in Results.Zip ( obj.Results, ( a, b ) => Tuple.Create ( a, b ) ) // Zip the rows together
                              where rows.Item1.Zip ( rows.Item2, ( a, b ) => Tuple.Create ( a, b ) ) // Zip the columns of each row together
                                                .Any ( cols => !cols.Item1.ToString ().Equals ( cols.Item2.ToString () ) ) // And compare the columns
                              select rows;

            return differences;
        }
        public void GetDifferences_NoDiff()
        {
            QueryData target = new QueryData ();
            QueryData obj = new QueryData ();

            target.Add ( new object[] { "a", 1, "c" } );
            obj.Add ( new object[] { "a", 1, "c" } );

            target.Add ( new object[] { "x", 2, "z" } );
            obj.Add ( new object[] { "x", 2, "z" } );

            Assert.AreEqual ( 0, target.GetDifferences ( obj ).Count () );
        }
		public QueryResults ()
		{
			this.Data = new QueryData ();
		}