Esempio n. 1
0
        public void TestLastDayOfYear()
        {
            var dateTimeNow       = DateTime.Now;
            var dateTimeOffsetNow = DateTimeOffset.Now;

            var ex = Assert.Throws <ArgumentException>(() => DateTimeCode.LastDayOfYear(dateTimeNow, "arg00"));

            Assert.That(ex.Message, Does.Contain("arg00"));
            Assert.That(ex.Message, Does.Contain("argument should be a last day of year"));

            ex = Assert.Throws <ArgumentException>(() => DateTimeCode.LastDayOfYear(dateTimeOffsetNow, "arg00"));
            Assert.That(ex.Message, Does.Contain("arg00"));
            Assert.That(ex.Message, Does.Contain("argument should be a last day of year"));

            Assert.DoesNotThrow(() => DateTimeCode.DateOnly(dateTimeNow.Date.LastDayOfYear(), "arg00"));
            Assert.DoesNotThrow(() => DateTimeCode.DateOnly(dateTimeOffsetNow.Date.LastDayOfYear(), "arg00"));
        }
Esempio n. 2
0
        public void TestDateOnlyAssertion()
        {
            var dateTimeNow       = DateTime.Now;
            var dateTimeOffsetNow = DateTimeOffset.Now;

            var ex = Assert.Throws <ArgumentException>(() => DateTimeCode.DateOnly(dateTimeNow, "arg00"));

            Assert.That(ex.Message, Does.Contain("arg00"));
            Assert.That(ex.Message, Does.Contain("argument should be a date without time component"));

            ex = Assert.Throws <ArgumentException>(() => DateTimeCode.DateOnly(dateTimeOffsetNow, "arg00"));
            Assert.That(ex.Message, Does.Contain("arg00"));
            Assert.That(ex.Message, Does.Contain("argument should be a date without time component"));

            Assert.DoesNotThrow(() => DateTimeCode.DateOnly(dateTimeNow.Date, "arg00"));
            Assert.DoesNotThrow(() => DateTimeCode.DateOnly(dateTimeOffsetNow.Date, "arg00"));
        }