Ejemplo n.º 1
0
        public void TestOvr()
        {
            Monthly plan = 201801;
            var     tar  = Monthly.FromString("2018.01");

            //哈希码(相同dot具有相同的哈希码)
            Assert.AreEqual(plan.GetHashCode(), tar.GetHashCode());
            tar++;
            Assert.AreNotEqual(plan.GetHashCode(), tar.GetHashCode());

            //格式化
            Assert.AreEqual(plan.ToString(), "2018/01");
            Assert.AreEqual(plan.ToString("yy/mm"), "18/01");
            Assert.AreEqual(Monthly.FromDot(501).ToString("yy/mm"), "05/01");
            Assert.AreEqual(plan.ToString("YYYY年m月"), "2018年1月");
            Assert.AreEqual(plan.ToString("公元YyYy年mM月,哈哈..."), "公元2018年01月,哈哈...");

            //比较相等
            Assert.IsTrue(plan.Equals(Monthly.FromDot(201801)));
            Assert.IsTrue(plan.Equals(new DateTime(2018, 1, 1)));
            Assert.IsTrue(plan.Equals((object)Monthly.FromDot(201801)));
            Assert.IsFalse(plan.Equals(Monthly.FromDot(201901)));
        }
Ejemplo n.º 2
0
 public string SearchQuery()
 {
     return(Today.ToString() + "/" + Weekly.ToString() + "/" + Monthly.ToString() + "/" + Annually.ToString() + "/" + UsedTotal.ToString());
 }