Beispiel #1
0
        public void TimeInstancePropertiesAndMethods()
        {
            Assert.DoesNotThrow(() =>
            {
                var now       = Datetime.now().time();
                var prevHours = now.addHours(-3);
                Assert.AreNotEqual(now, prevHours);

                var nextMinutes = now.addMinutes(15);
                Assert.AreNotEqual(now, nextMinutes);

                var prevSeconds = now.addSeconds(-30);
                Assert.AreNotEqual(now, prevSeconds);

                var nextMillis = now.addMilliseconds(534);
                Assert.AreNotEqual(now, nextMillis);

                var now2 = Datetime.newInstance(Date.today(), now).time();
                Assert.AreEqual(now, now2);

                var hash1 = now.hashCode();
                var hash2 = now2.hashCode();
                Assert.AreEqual(hash1, hash2);
                Assert.NotNull(now.toString());
            });
        }
Beispiel #2
0
        public void DatetimeInstancePropertiesAndMethods()
        {
            Assert.DoesNotThrow(() =>
            {
                var now      = Datetime.now();
                var tomorrow = now.addDays(1);
                Assert.AreNotEqual(now, tomorrow);
                Assert.False(now.isSameDay(tomorrow));

                var nowAgain = Datetime.newInstance(now.date(), now.time());
                Assert.AreEqual(now, nowAgain);

                var hash1 = now.hashCode();
                var hash2 = nowAgain.hashCode();
                Assert.AreEqual(hash1, hash2);

                var prevMonth = now.addMonths(-1);
                Assert.AreNotEqual(now, prevMonth);

                var nextYears = now.addYears(10);
                Assert.AreNotEqual(now, nextYears);

                var prevHours = now.addHours(-3);
                Assert.AreNotEqual(now, prevHours);

                var nextMinutes = now.addMinutes(15);
                Assert.AreNotEqual(now, nextMinutes);

                var prevSeconds = now.addSeconds(-30);
                Assert.AreNotEqual(now, prevSeconds);
                Assert.NotNull(now.toString());
            });
        }
Beispiel #3
0
        public void TimeStaticPropertiesAndMethods()
        {
            Assert.DoesNotThrow(() =>
            {
                var now    = Datetime.now().time();
                var notNow = Time.newInstance((now.hour() + 1) % 24,
                                              (now.minute() + 5) % 60, now.second(), now.millisecond());
                Assert.AreNotEqual(now, notNow);

                var then = Time.newInstance(12, 11, 10, 9);
                Assert.AreEqual(12, then.hour());
                Assert.AreEqual(11, then.minute());
                Assert.AreEqual(10, then.second());
                Assert.AreEqual(9, then.millisecond());
            });
        }
Beispiel #4
0
        public void GetPopulatedFieldsAsMapIsImplemented()
        {
            Assert.DoesNotThrow(() =>
            {
                var ul              = License;
                var now             = Datetime.now().addMinutes(2);
                ul.LastModifiedDate = now;

                var map = ul.getPopulatedFieldsAsMap();
                Assert.AreEqual(8, map.size());

                Assert.AreEqual("Hello", map.get(nameof(UserLicense.LicenseDefinitionKey)));
                Assert.AreEqual(123, map.get(nameof(UserLicense.TotalLicenses)));
                Assert.AreEqual("Trial", map.get(nameof(UserLicense.Status)));
                Assert.AreEqual(100, map.get(nameof(UserLicense.UsedLicenses)));
                Assert.AreEqual("ApexSharp", map.get(nameof(UserLicense.Name)));
                Assert.AreEqual(now, map.get(nameof(UserLicense.LastModifiedDate)));
            });
        }
Beispiel #5
0
        public void DatetimeStaticPropertiesAndMethods()
        {
            Assert.DoesNotThrow(() =>
            {
                var now    = Datetime.now();
                var notNow = Datetime.newInstance(now.year() + 1, (now.month() + 1) % 12, (now.day() + 1) % 28);

                var then = Datetime.newInstance(1970, 12, 11, 10, 9, 8);
                Assert.AreEqual(1970, then.year());
                Assert.AreEqual(12, then.month());
                Assert.AreEqual(11, then.day());
                Assert.AreEqual(10, then.hour());
                Assert.AreEqual(9, then.minute());
                Assert.AreEqual(8, then.second());

                var parsed = Datetime.parse("1970/12/11");
                Assert.AreEqual(1970, parsed.year());
                Assert.AreEqual(12, parsed.month());
                Assert.AreEqual(11, parsed.day());
            });
        }
Beispiel #6
0
        public void DatetimeInstancePropertiesAndMethods()
        {
            Assert.DoesNotThrow(() =>
            {
                var today    = Date.today();
                var tomorrow = today.addDays(1);
                Assert.AreNotEqual(today, tomorrow);
                Assert.False(today.isSameDay(tomorrow));

                var prevMonth = today.addMonths(-1);
                Assert.AreNotEqual(today, prevMonth);

                var nextYears = today.addYears(10);
                Assert.AreNotEqual(today, nextYears);

                var today2 = Datetime.newInstance(today, Datetime.now().time()).date();
                Assert.AreEqual(today, today2);

                var hash1 = today.hashCode();
                var hash2 = today2.hashCode();
                Assert.AreEqual(hash1, hash2);
                Assert.NotNull(today.toString());
            });
        }
Beispiel #7
0
 public Datetime now() => Datetime.now();