Beispiel #1
0
        public void Compare_BlankNullEmpty_True(object x, object y)
        {
            var comparer = new CellComparer();
            var result   = comparer.Compare(x, y, ColumnType.Text, null, null);

            Assert.That(result.AreEqual, Is.True);
        }
Beispiel #2
0
        protected override DataRow CompareRows(DataRow rx, DataRow ry)
        {
            var isRowOnError = false;

            for (int i = 0; i < rx.Table.Columns.Count; i++)
            {
                if (settings.GetColumnRole(i) == ColumnRole.Value)
                {
                    var x        = rx.IsNull(i) ? DBNull.Value : rx[i];
                    var y        = ry.IsNull(i) ? DBNull.Value : ry[i];
                    var rounding = settings.IsRounding(i) ? settings.GetRounding(i) : null;
                    var result   = CellComparer.Compare(x, y, settings.GetColumnType(i), settings.GetTolerance(i), rounding);

                    if (!result.AreEqual)
                    {
                        ry.SetColumnError(i, result.Message);
                        if (!isRowOnError)
                        {
                            isRowOnError = true;
                        }
                    }
                }
            }
            if (isRowOnError)
            {
                return(ry);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        public void Compare_ToValue_True(object value, ColumnType columnType)
        {
            var comparer = new CellComparer();
            var result   = comparer.Compare(value, "(value)", columnType, null, null);

            Assert.That(result.AreEqual, Is.True);
        }
        public void ShouldReturnOneWhenCell2IsNull()
        {
            //Arrange
            var    key01                    = "key01";
            string key02                    = null;
            var    expectedResult           = 1;
            var    cell01                   = new Cell <string, string>(key01);
            Cell <string, string> cell02    = null;
            var mockEqualityServiceProvider = MockRepository.GenerateMock <IComparer <string> >();
            var sut = new CellComparer <string, string>(mockEqualityServiceProvider);

            //Act
            var result = sut.Compare(cell01, cell02);

            //Assert
            Assert.That(result, Is.EqualTo(expectedResult));
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="R1"></param>
        /// <param name="R2"></param>
        /// <param name="K"></param>
        /// <returns></returns>
        public static int Compare(Record R1, Record R2, Key K)
        {
            int c = 0;

            for (int i = 0; i < K.Count; i++)
            {
                c = CellComparer.Compare(R1[K[i]], R2[K[i]]);
                if (K.Affinity(i) == KeyAffinity.Descending)
                {
                    c = -c;
                }
                if (c != 0)
                {
                    return(c);
                }
            }
            return(0);
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="R1"></param>
        /// <param name="R2"></param>
        /// <returns></returns>
        public static int Compare(Record R1, Record R2)
        {
            if (R1.Count != R2.Count)
            {
                throw new Exception("Record sizes do not match " + R1.Count.ToString() + " : " + R2.Count.ToString());
            }

            int c = 0;

            for (int i = 0; i < R1.Count; i++)
            {
                c = CellComparer.Compare(R1[i], R2[i]);
                if (c != 0)
                {
                    return(c);
                }
            }
            return(0);
        }
        public void ShouldReturnTheSameResultThatKeyComparerReturn()
        {
            //Arrange
            var key01                       = 1;
            var key02                       = 2;
            var cell01                      = new Cell <int, string>(key01);
            var cell02                      = new Cell <int, string>(key02);
            var keyComparerResult           = 99;
            var mockEqualityServiceProvider = MockRepository.GenerateMock <IComparer <int> >();

            mockEqualityServiceProvider.Stub(x => x.Compare(key01, key02)).Return(keyComparerResult);
            var sut = new CellComparer <int, string>(mockEqualityServiceProvider);


            //Act
            var result = sut.Compare(cell01, cell02);

            //Assert
            Assert.That(result, Is.EqualTo(keyComparerResult));
        }
Beispiel #8
0
        // Comparers //
        /// <summary>
        ///
        /// </summary>
        /// <param name="R1"></param>
        /// <param name="K1"></param>
        /// <param name="R2"></param>
        /// <param name="K2"></param>
        /// <returns></returns>
        public static int Compare(Record R1, Key K1, Record R2, Key K2)
        {
            if (K1.Count != K2.Count)
            {
                throw new Exception("Keys size do not match " + K1.Count.ToString() + " : " + K2.Count.ToString());
            }

            int c = 0;

            for (int i = 0; i < K1.Count; i++)
            {
                c = CellComparer.Compare(R1[K1[i]], R2[K2[i]]);
                if (K1.Affinity(i) == KeyAffinity.Descending || K2.Affinity(i) == KeyAffinity.Descending)
                {
                    c = -c;
                }
                if (c != 0)
                {
                    return(c);
                }
            }
            return(0);
        }
Beispiel #9
0
 public override Cell Evaluate(SpoolSpace Memory)
 {
     return(CellComparer.Compare(this._Children[0].Evaluate(Memory), this._Children[1].Evaluate(Memory).valueINT) >= 0 ? CellValues.True : CellValues.False);
 }