Esempio n. 1
0
        public void GetHashCodeWithVersions()
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable("MyTable");

            ds.Tables.Add(dt);
            dt.Columns.Add("col1");
            dt.Columns.Add("col2");
            DataRow r1 = dt.Rows.Add(new object [] { "foo", "bar" });
            DataRow r2 = dt.Rows.Add(new object [] { "foo", "bar" });

            ds.AcceptChanges();
            DataRowComparer <DataRow> c = DataRowComparer.Default;

            Assert.IsTrue(c.GetHashCode(r1) == c.GetHashCode(r2), "#1");

            /*
             * // LAMESPEC: .NET fails here
             * r2 ["col2"] = "baz";
             * r2.AcceptChanges ();
             * Assert.IsFalse (c.GetHashCode (r1) == c.GetHashCode (r2), "#2");
             * ds.AcceptChanges (); // now r2 original value is "baz"
             * r2 ["col2"] = "bar";
             * Assert.IsFalse (c.GetHashCode (r1) == c.GetHashCode (r2), "#3");
             * // LAMESPEC: .NET fails here
             * DataRow r3 = dt.Rows.Add (new object [] {"foo", "baz"});
             * Assert.IsFalse (c.GetHashCode (r1) == c.GetHashCode (r3), "#4");
             */
        }
Esempio n. 2
0
        public void GetHashCodeWithVersions()
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable("MyTable");

            ds.Tables.Add(dt);
            dt.Columns.Add("col1");
            dt.Columns.Add("col2");
            DataRow r1 = dt.Rows.Add(new object[] { "foo", "bar" });
            DataRow r2 = dt.Rows.Add(new object[] { "foo", "bar" });

            ds.AcceptChanges();
            DataRowComparer <DataRow> c = DataRowComparer.Default;

            Assert.True(c.GetHashCode(r1) == c.GetHashCode(r2), "#1");
        }
Esempio n. 3
0
        public void GetHashCode_Row_Null()
        {
            DataRowComparer <DataRow> c = DataRowComparer.Default;

            try {
                c.GetHashCode(null);
                Assert.Fail("#1");
            } catch (ArgumentNullException ex) {
                Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2");
                Assert.IsNull(ex.InnerException, "#3");
                Assert.IsNotNull(ex.Message, "#4");
                Assert.AreEqual("row", ex.ParamName, "#5");
            }
        }
Esempio n. 4
0
        public void GetHashCode_Row_Null()
        {
            DataRowComparer <DataRow> c = DataRowComparer.Default;

            try
            {
                c.GetHashCode(null);
                Assert.True(false, "#1");
            }
            catch (ArgumentNullException ex)
            {
                Assert.Equal(typeof(ArgumentNullException), ex.GetType());
                Assert.Null(ex.InnerException);
                Assert.NotNull(ex.Message);
                Assert.Equal("row", ex.ParamName);
            }
        }