//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "factory") public void test_sizeElements(String first, int second)
        public virtual void test_sizeElements(string first, int second)
        {
            ObjIntPair <string> test = ObjIntPair.of(first, second);

            assertEquals(test.size(), 2);
            assertEquals(test.elements(), ImmutableList.of(first, second));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "factory") public void test_toString(String first, int second)
        public virtual void test_toString(string first, int second)
        {
            ObjIntPair <string> test = ObjIntPair.of(first, second);
            string str = "[" + first + ", " + second + "]";

            assertEquals(test.ToString(), str);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "factory") public void test_of_getters(String first, int second)
        public virtual void test_of_getters(string first, int second)
        {
            ObjIntPair <string> test = ObjIntPair.of(first, second);

            assertEquals(test.First, first);
            assertEquals(test.Second, second, TOLERANCE);
        }
        public virtual void test_hashCode()
        {
            ObjIntPair <string> a1 = ObjIntPair.of("1", 1);
            ObjIntPair <string> a2 = ObjIntPair.of("1", 1);

            assertEquals(a1.GetHashCode(), a2.GetHashCode());
        }
        //-------------------------------------------------------------------------
        public virtual void test_equals()
        {
            ObjIntPair <string> a  = ObjIntPair.of("1", 2);
            ObjIntPair <string> a2 = ObjIntPair.of("1", 2);
            ObjIntPair <string> b  = ObjIntPair.of("1", 3);
            ObjIntPair <string> c  = ObjIntPair.of("2", 2);
            ObjIntPair <string> d  = ObjIntPair.of("2", 3);

            assertEquals(a.Equals(a), true);
            assertEquals(a.Equals(b), false);
            assertEquals(a.Equals(c), false);
            assertEquals(a.Equals(d), false);
            assertEquals(a.Equals(a2), true);

            assertEquals(b.Equals(a), false);
            assertEquals(b.Equals(b), true);
            assertEquals(b.Equals(c), false);
            assertEquals(b.Equals(d), false);

            assertEquals(c.Equals(a), false);
            assertEquals(c.Equals(b), false);
            assertEquals(c.Equals(c), true);
            assertEquals(c.Equals(d), false);

            assertEquals(d.Equals(a), false);
            assertEquals(d.Equals(b), false);
            assertEquals(d.Equals(c), false);
            assertEquals(d.Equals(d), true);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "factory") public void test_ofPair(String first, int second)
        public virtual void test_ofPair(string first, int second)
        {
            Pair <string, int>  pair = Pair.of(first, second);
            ObjIntPair <string> test = ObjIntPair.ofPair(pair);

            assertEquals(test.First, first);
            assertEquals(test.Second, second, TOLERANCE);
        }
        public virtual void test_equals_bad()
        {
            ObjIntPair <string> a = ObjIntPair.of("1", 1);

            assertEquals(a.Equals(null), false);
            assertEquals(a.Equals(ANOTHER_TYPE), false);
            object unrelatedType = Pair.of(Convert.ToInt32(1), Convert.ToInt32(1));

            assertEquals(a.Equals(unrelatedType), false);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = ClassCastException.class) public void test_compareTo_notComparable()
        public virtual void test_compareTo_notComparable()
        {
            ThreadStart notComparable = () =>
            {
            };
            ObjIntPair <ThreadStart> test1 = ObjIntPair.of(notComparable, 2);
            ObjIntPair <ThreadStart> test2 = ObjIntPair.of(notComparable, 2);

            test1.CompareTo(test2);
        }
Exemplo n.º 9
0
        //-----------------------------------------------------------------------
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (obj != null && obj.GetType() == this.GetType())
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ObjIntPair<?> other = (ObjIntPair<?>) obj;
                ObjIntPair <object> other = (ObjIntPair <object>)obj;
                return(JodaBeanUtils.equal(first, other.first) && (second == other.second));
            }
            return(false);
        }
        //-------------------------------------------------------------------------
        public virtual void test_compareTo()
        {
            ObjIntPair <string> p12 = ObjIntPair.of("1", 2);
            ObjIntPair <string> p13 = ObjIntPair.of("1", 3);
            ObjIntPair <string> p21 = ObjIntPair.of("2", 1);

            assertTrue(p12.CompareTo(p12) == 0);
            assertTrue(p12.CompareTo(p13) < 0);
            assertTrue(p12.CompareTo(p21) < 0);

            assertTrue(p13.CompareTo(p12) > 0);
            assertTrue(p13.CompareTo(p13) == 0);
            assertTrue(p13.CompareTo(p21) < 0);

            assertTrue(p21.CompareTo(p12) > 0);
            assertTrue(p21.CompareTo(p13) > 0);
            assertTrue(p21.CompareTo(p21) == 0);
        }
Exemplo n.º 11
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Compares the pair based on the first element followed by the second element.
        /// <para>
        /// The first element must be {@code Comparable}.
        ///
        /// </para>
        /// </summary>
        /// <param name="other">  the other pair </param>
        /// <returns> negative if this is less, zero if equal, positive if greater </returns>
        /// <exception cref="ClassCastException"> if the object is not comparable </exception>
        public int CompareTo(ObjIntPair <A> other)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: return com.google.common.collect.ComparisonChain.start().compare((Comparable<?>) first, (Comparable<?>) other.first).compare(second, other.second).result();
            return(ComparisonChain.start().compare((IComparable <object>)first, (IComparable <object>)other.first).compare(second, other.second).result());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "factory") public void test_toPair(String first, int second)
        public virtual void test_toPair(string first, int second)
        {
            ObjIntPair <string> test = ObjIntPair.of(first, second);

            assertEquals(test.toPair(), Pair.of(first, second));
        }
        public virtual void coverage()
        {
            ObjIntPair <string> test = ObjIntPair.of("1", 1);

            TestHelper.coverImmutableBean(test);
        }