예제 #1
0
        public void should_compare_two_null_values()
        {
            AwesomeDateTimeOffset nullDate = null;

            Assert.True(nullDate == null);
            Assert.False(nullDate != null);
        }
예제 #2
0
        public void should_compare_with_null()
        {
            var date = new AwesomeDateTimeOffset(DateTime.UtcNow, TimeSpan.FromHours(8));

            Assert.False(date.Equals(null));
            Assert.False(date == null);
            Assert.True(date != null);
        }
예제 #3
0
        public void should_at_least_get_different_hash_code_on_below_times()
        {
            var time = new AwesomeDateTimeOffset(
                new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), new TimeSpan(8, 0, 0));
            var different = new AwesomeDateTimeOffset(
                new DateTime(1999, 12, 30, 16, 0, 0, DateTimeKind.Utc), new TimeSpan(0, 0, 0));

            Assert.NotEqual(time.GetHashCode(), different.GetHashCode());
        }
예제 #4
0
        public void should_get_same_hashcode_on_same_time()
        {
            var time = new AwesomeDateTimeOffset(
                new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), new TimeSpan(8, 0, 0));
            var sameTime = new AwesomeDateTimeOffset(
                new DateTime(1999, 12, 31, 16, 0, 0, DateTimeKind.Utc), new TimeSpan(0, 0, 0));

            Assert.Equal(time.GetHashCode(), sameTime.GetHashCode());
        }
예제 #5
0
        public void should_compare_dates_2()
        {
            var time = new AwesomeDateTimeOffset(
                new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), new TimeSpan(8, 0, 0));
            var differentTime = new AwesomeDateTimeOffset(
                new DateTime(1999, 12, 30, 16, 0, 0, DateTimeKind.Utc), new TimeSpan(0, 0, 0));

            Assert.False(time == differentTime);
            Assert.True(time != differentTime);
            Assert.False(time.Equals(differentTime));
        }
예제 #6
0
        public void should_modify_offset()
        {
            var time = new AwesomeDateTimeOffset(
                new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), new TimeSpan(8, 0, 0));
            var sameTime = new AwesomeDateTimeOffset(
                new DateTime(1999, 12, 31, 16, 0, 0, DateTimeKind.Utc), new TimeSpan(0, 0, 0));

            sameTime.SetOffset(new TimeSpan(2, 0, 0));

            Assert.True(time.Equals(sameTime));
            Assert.True(time == sameTime);
            Assert.False(time != sameTime);
            Assert.Equal(time.GetHashCode(), sameTime.GetHashCode());
        }
예제 #7
0
        public void should_compare_with_other_type()
        {
            var date = new AwesomeDateTimeOffset(DateTime.UtcNow, TimeSpan.FromHours(8));

            Assert.False(date.Equals("hello"));
        }