Example #1
0
        public void CompareTo_ObjectTestStruct_0()
        {
            object other = TestStruct;

            var exp = 0;
            var act = TestStruct.CompareTo(other);

            Assert.AreEqual(exp, act);
        }
Example #2
0
        public override int CompareTo(object obj)
        {
            if (!(obj is BuildVersion))
            {
                return(-1);
            }

            var other = (BuildVersion)obj;
            int c     = Year.CompareTo(other.Year);

            if (c != 0)
            {
                return(c);
            }
            c = Month.CompareTo(other.Month);
            if (c != 0)
            {
                return(c);
            }
            c = Day.CompareTo(other.Day);
            if (c != 0)
            {
                return(c);
            }
            return(Build.CompareTo(other.Build));
        }
Example #3
0
        public void Should_compare_with_null_instance(double value)
        {
            var instance = new Year(value);

            Assert.IsFalse(instance.Equals(null), "Equals");
            Assert.AreEqual(1, instance.CompareTo(null), "CompareTo");
        }
Example #4
0
        public int CompareTo(object o)
        {
            KeyStruct key    = o as KeyStruct;
            int       result = Year.CompareTo(key.Year);

            if (result != 0)
            {
                return(result);
            }
            result = Month.CompareTo(key.Month);
            if (result != 0)
            {
                return(result);
            }
            result = Day.CompareTo(key.Day);
            if (result != 0)
            {
                return(result);
            }
            result = Hour.CompareTo(key.Hour);
            if (result != 0)
            {
                return(result);
            }
            result = Min.CompareTo(key.Min);
            if (result != 0)
            {
                return(result);
            }
            result = ID.CompareTo(key.ID);
            return(result);
        }
        public int CompareTo(object o)
        {
            SimpleDateTime key    = o as SimpleDateTime;
            int            result = Year.CompareTo(key.Year);

            if (result != 0)
            {
                return(result);
            }
            result = Month.CompareTo(key.Month);
            if (result != 0)
            {
                return(result);
            }
            result = Day.CompareTo(key.Day);
            if (result != 0)
            {
                return(result);
            }
            result = Hour.CompareTo(key.Hour);
            if (result != 0)
            {
                return(result);
            }
            result = Min.CompareTo(key.Min);
            return(result);
        }
Example #6
0
        private int CompareTo(IGameDateTime gameDateTime)
        {
            if (gameDateTime == null)
            {
                throw new NullReferenceException("Game date time can not be null.");
            }

            if (Year != gameDateTime.Year)
            {
                return(Year.CompareTo(gameDateTime.Year));
            }
            else if (Month != gameDateTime.Month)
            {
                return(Month.CompareTo(gameDateTime.Month));
            }
            else if (Day != gameDateTime.Day)
            {
                return(Day.CompareTo(gameDateTime.Day));
            }
            else if (Hour != gameDateTime.Hour)
            {
                return(Hour.CompareTo(gameDateTime.Hour));
            }
            else if (Minute != gameDateTime.Minute)
            {
                return(Minute.CompareTo(gameDateTime.Minute));
            }

            return(0);
        }
Example #7
0
        public int CompareTo(object?obj)
        {
            var other = obj as VideoGameDetails;

            if (other == null)
            {
                return(-1);
            }

            var year_comparison = Year.CompareTo(other.Year);

            if (year_comparison != 0)
            {
                return(year_comparison);
            }
            var genre_comparison = string.Compare(Genre, other.Genre, StringComparison.Ordinal);

            if (genre_comparison != 0)
            {
                return(genre_comparison);
            }
            var platform_comparison = string.Compare(Platform, other.Platform, StringComparison.Ordinal);

            if (platform_comparison != 0)
            {
                return(platform_comparison);
            }
            return(Rank.CompareTo(other.Rank));
        }
        public int CompareTo(object obj)
        {
            var pbld = obj as PbLocalDate;

            if (pbld == null)
            {
                return(1);
            }

            if (pbld.Year != Year)
            {
                return(Year.CompareTo(pbld.Year));
            }

            if (pbld.Month != Month)
            {
                return(Month.CompareTo(pbld.Month));
            }

            if (pbld.Day != Day)
            {
                return(Day.CompareTo(pbld.Day));
            }

            return(0);
        }
Example #9
0
            public int CompareTo(object obj)
            {
                ShiftEvent e    = (ShiftEvent)obj;
                int        year = Year.CompareTo(e.Year);

                if (year != 0)
                {
                    return(year);
                }

                int month = Month.CompareTo(e.Month);

                if (month != 0)
                {
                    return(month);
                }

                int day = Day.CompareTo(e.Day);

                if (day != 0)
                {
                    return(day);
                }

                return(Minute.CompareTo(e.Minute));
            }
Example #10
0
        public int CompareTo(Book other)
        {
            int result = Year.CompareTo(other.Year);

            if (result == 0)
            {
                result = Title.CompareTo(other.Title);
            }

            return(result);

            // С долното дава 90 от 100! Гърми на последния тест.

            //if (Year != other.Year)
            //{
            //    return Year - other.Year;
            //}

            //if (Title != other.Title)
            //{
            //    return Title.CompareTo(other.Title);
            //}

            //return 0;
        }
Example #11
0
 public int CompareTo(Earnings other)
 {
     return
         (Year == other.Year
             ? Month == other.Month ? Day.CompareTo(other.Day) :
          Month.CompareTo(other.Month)
             : Year.CompareTo(other.Year));
 }
Example #12
0
        public void Should_compare_with_another_type_of_instance(double value)
        {
            var    instance1 = new Year(value);
            object instance2 = value;

            Assert.IsFalse(instance1.Equals(instance2), "Equals");
            Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo");
        }
Example #13
0
 public int CompareTo(Book other)
 {
     if (Year != other.Year)
     {
         return(Year.CompareTo(other.Year));
     }
     return(Title.CompareTo(other.Title));
 }
Example #14
0
        public int CompareTo([AllowNull] Book other)
        {
            if (this.Year.CompareTo(other.Year) == 0)
            {
                return(Title.CompareTo(other.Title));
            }

            return(Year.CompareTo(other.Year));
        }
        public int CompareTo(Book other)
        {
            if (this.Year == other.Year)
            {
                return(this.Title.CompareTo(other.Title));
            }

            return(Year.CompareTo(other.Year));
        }
Example #16
0
        // Implementation of IComparable<Book> interface
        public int CompareTo(Book book)
        {
            if (Year.Equals(book.Year))
            {
                return(Name.CompareTo(book.Name));
            }

            return(Year.CompareTo(book.Year));
        }
        public int CompareTo(Book other)
        {
            int compere = Year.CompareTo(other.Year);

            if (compere == 0)
            {
                return(Title.CompareTo(other.Title));
            }
            return(compere);
        }
Example #18
0
        public int CompareTo(Book other)
        {
            int comparisonResult = Year.CompareTo(other.Year);

            if (comparisonResult == 0)
            {
                comparisonResult = Title.CompareTo(other.Title);
            }
            return(comparisonResult);
        }
Example #19
0
        public int CompareTo(RetailWeekData other)
        {
            int yearComp = Year.CompareTo(other.Year);

            if (yearComp != 0)
            {
                return(yearComp);
            }
            return(Week.CompareTo(other.Week));
        }
Example #20
0
        public int CompareTo(Book other)
        {
            int result = Year.CompareTo(other.Year);

            if (result == 0)
            {
                result = Title.CompareTo(other.Title);
            }
            return(result);
        }
Example #21
0
        public int CompareTo(Book otherBook)
        {
            var result = Year.CompareTo(otherBook.Title);

            if (result == 0)
            {
                result = Title.CompareTo(otherBook.Title);
            }
            return(result);
        }
Example #22
0
        public int CompareTo(MonthModel other)
        {
            int compare = Year.CompareTo(other.Year);

            if (compare == 0)
            {
                compare = Month.CompareTo(other.Month);
            }

            return(compare);
        }
Example #23
0
        public int CompareTo(Session other)
        {
            var ct = Year.CompareTo(other.Year) * -1;

            if (ct == 0)
            {
                ct = Season.CompareTo(other.Season);
            }

            return(ct);
        }
Example #24
0
        public void Should_compare_with_same_value(double value)
        {
            var baseInstance  = new Year(value);
            var otherInstance = new Year(value);

            Assert.IsTrue(baseInstance.Equals(otherInstance), "Equals");
            Assert.IsTrue(baseInstance.Equals((object)otherInstance), "Equals object");

            Assert.IsTrue(baseInstance == otherInstance, "==");
            Assert.IsFalse(baseInstance != otherInstance, "!=");

            Assert.AreEqual(0, baseInstance.CompareTo(otherInstance), "CompareTo");
            Assert.AreEqual(0, baseInstance.CompareTo((object)otherInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < otherInstance, "<");
            Assert.IsFalse(baseInstance > otherInstance, ">");

            Assert.IsTrue(baseInstance <= otherInstance, "<=");
            Assert.IsTrue(baseInstance >= otherInstance, ">=");
        }
Example #25
0
        public void Should_compare_with_smaller_value(double baseValue, double smallerValue)
        {
            var baseInstance    = new Year(baseValue);
            var smallerInstance = new Year(smallerValue);

            Assert.IsFalse(baseInstance.Equals(smallerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)smallerInstance), "Equals object");

            Assert.IsFalse(baseInstance == smallerInstance, "==");
            Assert.IsTrue(baseInstance != smallerInstance, "!=");

            Assert.AreEqual(+1, baseInstance.CompareTo(smallerInstance), "CompareTo");
            Assert.AreEqual(+1, baseInstance.CompareTo((object)smallerInstance), "CompareTo object");

            Assert.IsFalse(baseInstance < smallerInstance, "<");
            Assert.IsTrue(baseInstance > smallerInstance, ">");

            Assert.IsFalse(baseInstance <= smallerInstance, "<=");
            Assert.IsTrue(baseInstance >= smallerInstance, ">=");
        }
Example #26
0
        public void Should_compare_with_bigger_value(double baseValue, double biggerValue)
        {
            var baseInstance   = new Year(baseValue);
            var biggerInstance = new Year(biggerValue);

            Assert.IsFalse(baseInstance.Equals(biggerInstance), "Equals");
            Assert.IsFalse(baseInstance.Equals((object)biggerInstance), "Equals object");

            Assert.IsFalse(baseInstance == biggerInstance, "==");
            Assert.IsTrue(baseInstance != biggerInstance, "!=");

            Assert.AreEqual(-1, baseInstance.CompareTo(biggerInstance), "CompareTo");
            Assert.AreEqual(-1, baseInstance.CompareTo((object)biggerInstance), "CompareTo object");

            Assert.IsTrue(baseInstance < biggerInstance, "<");
            Assert.IsFalse(baseInstance > biggerInstance, ">");

            Assert.IsTrue(baseInstance <= biggerInstance, "<=");
            Assert.IsFalse(baseInstance >= biggerInstance, ">=");
        }
Example #27
0
 public int CompareTo([AllowNull] XTerm other)
 {
     if (Year == other.Year)
     {
         return(Term.CompareTo(other.Term));
     }
     else
     {
         return(Year.CompareTo(other.Year));
     }
 }
Example #28
0
 public int CompareTo(SupportedYear other)
 {
     if (ReferenceEquals(this, other))
     {
         return(0);
     }
     if (ReferenceEquals(null, other))
     {
         return(1);
     }
     return(Year.CompareTo(other.Year));
 }
 public int CompareTo(SpannerDate other)
 {
     if (Year != other.Year)
     {
         return(Year.CompareTo(other.Year));
     }
     if (Month != other.Month)
     {
         return(Month.CompareTo(other.Month));
     }
     return(Day.CompareTo(other.Day));
 }
    public int CompareTo(Book other)
    {
        int result = Year.CompareTo(other.Year);

        // if years are equal, sort books alphabetically according to their title

        if (result == 0)
        {
            result = this.Title.CompareTo(other.Title);
        }

        return(result);
    }