public void LessThan_WhenLess_ReturnsTrue()
        {
            _dayTime = _dayTime.CreateTimestamp(1440);
            _dayTime.Next();
            DayTime lessDay  = new DayTime((int)DayTime.Days.Sun, 0);
            DayTime lessTime = new DayTime((int)DayTime.Days.Mon, 0);

            Assert.IsTrue(lessDay.LessThan(_dayTime));
            Assert.IsFalse(_dayTime.LessThan(lessDay));
            Assert.IsTrue(lessTime.LessThan(_dayTime));
            Assert.IsFalse(_dayTime.LessThan(lessTime));
            Assert.IsFalse(_dayTime.Equals(lessDay));
            Assert.IsFalse(_dayTime.Equals(lessTime));
        }
示例#2
0
    void calcTimeDisplay()
    {
        DayTime newTime = curDayTime;

        if (normalizedTime < 0.16f)
        {
            newTime = DayTime.sunrise;
        }
        else if (normalizedTime < 0.5f)
        {
            newTime = DayTime.noon;
        }
        else if (normalizedTime < 0.66f)
        {
            newTime = DayTime.sunset;
        }
        else
        {
            newTime = DayTime.midnight;
        }

        if (!newTime.Equals(curDayTime))
        {
            curDayTime = newTime;
            if (onDayTimeChangeCallback != null)
            {
                onDayTimeChangeCallback.Invoke();
            }
        }
    }
        public void Equals_WhenEqual_ReturnsTrue()
        {
            DayTime other = new DayTime();

            Assert.IsTrue(_dayTime.Equals(other));
            Assert.IsFalse(_dayTime.LessThan(other));
        }
示例#4
0
        public void Should_BeComparable()
        {
            var now = DateTime.Now;

            var date1 = new DayTime(now);
            var date2 = new DayTime(now);

            var isEqual = date1
                          .Equals(date2);

            isEqual.Should().BeTrue();

            var date3 = new DayTime(now.AddDays(2));

            isEqual = date1
                      .Equals(date3);

            isEqual.Should().BeFalse();
        }