Ejemplo n.º 1
0
        public void be_able_to_be_compared_to_times_greater_than_it()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(09, 45);

            Assert.True(time1.IsGreaterThan(time2));
        }
Ejemplo n.º 2
0
        public void not_be_equal_when_different_to_another_time_using_hash_code_comparison()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(11, 45);

            Assert.True(time1.GetHashCode() != time2.GetHashCode());
        }
Ejemplo n.º 3
0
        public void not_be_equal_when_different_to_another_time_that_isnt_explicitly_typed()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = (object)new TwentyFourHourTime(11, 45);

            Assert.False(time1.Equals(time2));
        }
Ejemplo n.º 4
0
        public void not_be_equal_when_different_to_another_time_using_not_equals_operator()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(09, 45);

            Assert.True(time1 != time2);
        }
Ejemplo n.º 5
0
        public void be_equal_when_the_same_as_another_time_using_equality_operator()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(10, 45);

            Assert.True(time1 == time2);
        }
Ejemplo n.º 6
0
        public void be_equal_when_the_same_as_another_time_using_hash_code_comparison()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(10, 45);

            Assert.True(time1.GetHashCode() == time2.GetHashCode());
        }
Ejemplo n.º 7
0
        public void be_able_to_be_created_from_a_datetime()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = TwentyFourHourTime.From(new DateTime(2017, 5, 1, 10, 45, 0));

            Assert.True(time1.Equals(time2));
        }
Ejemplo n.º 8
0
        public void be_equal_when_same_another_time_that_isnt_explicitly_typed()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = (object)new TwentyFourHourTime(10, 45);

            Assert.True(time1.Equals(time2));
        }
Ejemplo n.º 9
0
        public void be_equal_when_the_same_as_another_time_when_explicitly_typed()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(10, 45);

            Assert.True(time1.Equals(time2));
        }
Ejemplo n.º 10
0
        public void be_able_to_be_compared_to_times_less_than_or_equal_to_it_using_operator()
        {
            var time1 = new TwentyFourHourTime(09, 44);
            var time2 = new TwentyFourHourTime(09, 45);

            Assert.True(time1 <= time2);
        }
Ejemplo n.º 11
0
        public void be_able_to_be_compared_to_times_greater_than_it_using_operator()
        {
            var time1 = new TwentyFourHourTime(10, 45);
            var time2 = new TwentyFourHourTime(09, 45);

            Assert.True(time1 > time2);
        }
Ejemplo n.º 12
0
        public void be_able_to_be_compared_to_times_less_than_it()
        {
            var time1 = new TwentyFourHourTime(08, 45);
            var time2 = new TwentyFourHourTime(09, 45);

            Assert.True(time1.IsLessThan(time2));
        }
Ejemplo n.º 13
0
        public void be_able_to_determine_whether_not_between_two_other_times(int minutes)
        {
            var startTime   = new TwentyFourHourTime(19, 15);
            var endTime     = new TwentyFourHourTime(19, 30);
            var timeInRange = new TwentyFourHourTime(19, minutes);

            Assert.False(timeInRange.IsBetween(startTime, endTime));
        }
Ejemplo n.º 14
0
        public void be_able_to_convert_itself_to_correct_string_representation()
        {
            var time = new TwentyFourHourTime(9, 30);

            Assert.Equal("09:30", time.ToString());
        }