Example #1
0
        public void Empty()
        {
            Csla.SmartDate d2 = new Csla.SmartDate();
            Csla.SmartDate d3;

            d3 = new Csla.SmartDate(d2.Add(new TimeSpan(30, 0, 0, 0)));
            Assert.AreEqual(d2, d3, "Dates should be equal");
            Assert.AreEqual("", d2.Text, "Text should be empty");

            d3 = new Csla.SmartDate(d2.Subtract(new TimeSpan(30, 0, 0, 0)));
            Assert.AreEqual(d2, d3, "Dates should be equal");
            Assert.AreEqual("", d2.Text, "Text should be empty");

            d3 = new Csla.SmartDate();
            Assert.AreEqual(0, d2.CompareTo(d3), "d2 and d3 should be the same");
            Assert.IsTrue(d2.Equals(d3), "d2 and d3 should be the same");
            Assert.IsTrue(Csla.SmartDate.Equals(d2, d3), "d2 and d3 should be the same");

            d3.Date = DateTime.Now;
            Assert.AreEqual(-1, d2.CompareTo(d3), "d2 and d3 should not be the same");
            Assert.AreEqual(1, d3.CompareTo(d2), "d2 and d3 should not be the same");
            Assert.IsFalse(d2.Equals(d3), "d2 and d3 should not be the same");
            Assert.IsFalse(Csla.SmartDate.Equals(d2, d3), "d2 and d3 should not be the same");
            Assert.IsFalse(d3.Equals(d2), "d2 and d3 should not be the same");
            Assert.IsFalse(Csla.SmartDate.Equals(d3, d2), "d2 and d3 should not be the same");
        }
Example #2
0
        public void Subtract()
        {
            Csla.SmartDate d2 = new Csla.SmartDate();
            Csla.SmartDate d3;

            d2.Date = new DateTime(2005, 1, 1);
            d3      = new Csla.SmartDate(d2.Subtract(new TimeSpan(30, 0, 0, 0)));
            Assert.AreEqual(DateAndTime.DateAdd(DateInterval.Day, -30, d2.Date), d3.Date, "Dates should be equal");

            Assert.AreEqual(30, ((TimeSpan)(d2 - d3)).Days, "Should be 30 days different");
            Assert.AreEqual(d3, d2 - new TimeSpan(30, 0, 0, 0, 0), "Should be equal");
        }