Ejemplo n.º 1
0
        public void CompareTo()
        {
            string  testString = "This is a test string";
            SqlGuid test1      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE");
            SqlGuid test2      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE");
            SqlGuid test3      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE");

            Assert.True(_test1.CompareTo(_test3) < 0);
            Assert.True(_test4.CompareTo(_test1) > 0);
            Assert.Equal(0, _test3.CompareTo(_test2));
            Assert.True(_test4.CompareTo(SqlGuid.Null) > 0);
            Assert.True(test1.CompareTo(test2) > 0);
            Assert.True(test3.CompareTo(test2) < 0);

            Assert.Throws <ArgumentException>(() => _test1.CompareTo(testString));
        }
Ejemplo n.º 2
0
        public int CompareTo(object obj)
        {
            if (obj is SqlEntityReference er)
            {
                obj = er._guid;
            }

            return(_guid.CompareTo(obj));
        }
Ejemplo n.º 3
0
        public void TableSortGuidFileGdb()
        {
            IFeatureWorkspace featureWs =
                WorkspaceUtils.OpenFileGdbFeatureWorkspace(TestData.GetArealeFileGdbPath());
            //IFeatureWorkspace featureWs = OpenTestWorkspace();

            ITable table = DatasetUtils.OpenTable(featureWs, "TLM_NUTZUNGSAREAL");

            ITableSort tableSort = new TableSortClass();

            tableSort.Table  = table;
            tableSort.Fields = "UUID";

            tableSort.Sort(null);

            ICursor cursor = tableSort.Rows;

            IRow row;
            Guid lastValue = Guid.Empty;

            while ((row = cursor.NextRow()) != null)
            {
                object value = row.get_Value(1);

                Assert.False(value == DBNull.Value, "Empty UUID field");

                var         currentGuid  = new Guid((string)value);
                IComparable currentValue = currentGuid;

                Console.WriteLine(currentValue);

                if (lastValue != Guid.Empty)
                {
                    // ITableSort on a GUID field in a file GDB does not sort the byte array or at least not in an obvious way
                    byte[] currentGuidAsByteArray = currentGuid.ToByteArray();
                    byte[] lastGuidAsByteArray    = lastValue.ToByteArray();
                    int    byteArrayCompare       = ByteArrayCompare(currentGuidAsByteArray,
                                                                     lastGuidAsByteArray);
                    //Assert.True(byteArrayCompare > 0, "Different compare algorithm from byte array");

                    // ITableSort on a GUID field in a file GDB does not sort the same way as SqlGuid in .NET (i.e. SQL Server sorting)
                    var sqlGuid        = new SqlGuid(currentGuid);
                    int sqlGuidCompare = sqlGuid.CompareTo(new SqlGuid(lastValue));
                    //Assert.True(sqlGuidCompare < 0, "Different compare algorithm from sql server");

                    // ITableSort on a GUID field in a file GDB does not sort the same way as Guid in .NET
                    IComparable comparableGuid = lastValue;
                    int         guidCompare    = comparableGuid.CompareTo(currentValue);
                    //Assert.True(guidCompare < 0, "Different compare algorithm from .Net.");
                }

                lastValue = currentGuid;
            }
        }
Ejemplo n.º 4
0
        public static int Compare(Guid guidA, Guid guidB, int mode)
        {
            if (mode == 1)
            {
                SqlGuid sqlGuidA = guidA;
                SqlGuid sqlGuidB = guidB;
                return(sqlGuidA.CompareTo(sqlGuidB));
            }

            return(String.Compare(guidA.ToString(), guidB.ToString()));
        }
Ejemplo n.º 5
0
        public void CompareTo()
        {
            String  TestString = "This is a test string";
            SqlGuid test1      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE");
            SqlGuid test2      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE");
            SqlGuid test3      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE");

            Assert.IsTrue(Test1.CompareTo(Test3) < 0, "#D01");
            Assert.IsTrue(Test4.CompareTo(Test1) > 0, "#D02");
            Assert.IsTrue(Test3.CompareTo(Test2) == 0, "#D03");
            Assert.IsTrue(Test4.CompareTo(SqlGuid.Null) > 0, "#D04");
            Assert.IsTrue(test1.CompareTo(test2) > 0, "#D05");
            Assert.IsTrue(test3.CompareTo(test2) < 0, "#D06");

            try {
                Test1.CompareTo(TestString);
                Assert.Fail("#D05");
            } catch (Exception e) {
                Assert.AreEqual(typeof(ArgumentException), e.GetType(), "#D06");
            }
        }
Ejemplo n.º 6
0
        public void CompareTo()
        {
            string  TestString = "This is a test string";
            SqlGuid test1      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-3EEEEEEEEEEE");
            SqlGuid test2      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-2EEEEEEEEEEE");
            SqlGuid test3      = new SqlGuid("1AAAAAAA-BBBB-CCCC-DDDD-1EEEEEEEEEEE");

            Assert.True(_test1.CompareTo(_test3) < 0);
            Assert.True(_test4.CompareTo(_test1) > 0);
            Assert.True(_test3.CompareTo(_test2) == 0);
            Assert.True(_test4.CompareTo(SqlGuid.Null) > 0);
            Assert.True(test1.CompareTo(test2) > 0);
            Assert.True(test3.CompareTo(test2) < 0);

            try
            {
                _test1.CompareTo(TestString);
                Assert.False(true);
            }
            catch (Exception e)
            {
                Assert.Equal(typeof(ArgumentException), e.GetType());
            }
        }
Ejemplo n.º 7
0
 public static int CompareTo(this SqlGuid sqlGuidA, SqlGuid sqlGuidB) => sqlGuidA.CompareTo(sqlGuidB);