Exemple #1
0
        public void 变爻Test()
        {
            Gua gua = new Gua("火雷噬嗑", "山天大畜", HHTime.Parse("/寅/辛酉/"));

            Assert.AreEqual("父母", gua.Lines[0].变爻.五神);
            Assert.AreEqual("甲子", gua.Lines[0].变爻.干支.Name);
            Assert.AreEqual(1, gua.变卦.阴阳(0));
            Assert.AreEqual(阴阳.少阳, gua.Lines[0].变爻.阴阳);

            Assert.AreEqual("兄弟", gua.Lines[1].变爻.五神);
            Assert.AreEqual("甲寅", gua.Lines[1].变爻.干支.Name);
            Assert.AreEqual(1, gua.变卦.阴阳(1));
            Assert.AreEqual(阴阳.少阳, gua.Lines[1].变爻.阴阳);

            Assert.AreEqual("妻财", gua.Lines[2].变爻.五神);
            Assert.AreEqual("甲辰", gua.Lines[2].变爻.干支.Name);
            Assert.AreEqual(1, gua.变卦.阴阳(2));
            Assert.AreEqual(阴阳.少阳, gua.Lines[2].变爻.阴阳);

            Assert.AreEqual("妻财", gua.Lines[3].变爻.五神);
            Assert.AreEqual("丙戌", gua.Lines[3].变爻.干支.Name);
            Assert.AreEqual(0, gua.变卦.阴阳(3));
            Assert.AreEqual(阴阳.少阴, gua.Lines[3].变爻.阴阳);

            Assert.AreEqual("父母", gua.Lines[4].变爻.五神);
            Assert.AreEqual("丙子", gua.Lines[4].变爻.干支.Name);
            Assert.AreEqual(0, gua.变卦.阴阳(4));
            Assert.AreEqual(阴阳.少阴, gua.Lines[4].变爻.阴阳);

            Assert.AreEqual("兄弟", gua.Lines[5].变爻.五神);
            Assert.AreEqual("丙寅", gua.Lines[5].变爻.干支.Name);
            Assert.AreEqual(1, gua.变卦.阴阳(5));
            Assert.AreEqual(阴阳.少阳, gua.Lines[5].变爻.阴阳);
        }
Exemple #2
0
        public void 伏爻Test()
        {
            Gua gua = new Gua("山火贲", "离为火", HHTime.Parse("/寅/辛酉/"));

            Assert.AreEqual("兄弟", gua.Lines[0].伏爻.五神);
            Assert.AreEqual("丙辰", gua.Lines[0].伏爻.干支.Name);

            Assert.AreEqual("父母", gua.Lines[1].伏爻.五神);
            Assert.AreEqual("丙午", gua.Lines[1].伏爻.干支.Name);

            Assert.AreEqual("子孙", gua.Lines[2].伏爻.五神);
            Assert.AreEqual("丙申", gua.Lines[2].伏爻.干支.Name);

            gua = new Gua("火雷噬嗑", "山天大畜", HHTime.Parse("/寅/辛酉/"));
            Assert.AreEqual("妻财", gua.Lines[0].伏爻.五神);
            Assert.AreEqual("辛丑", gua.Lines[0].伏爻.干支.Name);

            Assert.AreEqual("父母", gua.Lines[1].伏爻.五神);
            Assert.AreEqual("辛亥", gua.Lines[1].伏爻.干支.Name);

            Assert.AreEqual("官鬼", gua.Lines[2].伏爻.五神);
            Assert.AreEqual("辛酉", gua.Lines[2].伏爻.干支.Name);

            Assert.AreEqual("妻财", gua.Lines[3].伏爻.五神);
            Assert.AreEqual("辛未", gua.Lines[3].伏爻.干支.Name);

            Assert.AreEqual("子孙", gua.Lines[4].伏爻.五神);
            Assert.AreEqual("辛巳", gua.Lines[4].伏爻.干支.Name);

            Assert.AreEqual("兄弟", gua.Lines[5].伏爻.五神);
            Assert.AreEqual("辛卯", gua.Lines[5].伏爻.干支.Name);
        }
Exemple #3
0
        public void Gua六神Test()
        {
            Gua gua = new Gua("震为雷", "地雷复", HHTime.Parse("/辛丑/庚申/"));

            Assert.IsNotNull(gua);

            Assert.AreEqual("白虎", gua.Lines[0].六神);
            Assert.AreEqual("玄武", gua.Lines[1].六神);
            Assert.AreEqual("青龙", gua.Lines[2].六神);
            Assert.AreEqual("朱雀", gua.Lines[3].六神);
            Assert.AreEqual("勾陈", gua.Lines[4].六神);
            Assert.AreEqual("螣蛇", gua.Lines[5].六神);

            gua = new Gua("震为雷", "地雷复", HHTime.Parse("/辛丑/己巳/"));
            Assert.IsNotNull(gua);

            Assert.AreEqual("螣蛇", gua.Lines[0].六神);
            Assert.AreEqual("白虎", gua.Lines[1].六神);
            Assert.AreEqual("玄武", gua.Lines[2].六神);
            Assert.AreEqual("青龙", gua.Lines[3].六神);
            Assert.AreEqual("朱雀", gua.Lines[4].六神);
            Assert.AreEqual("勾陈", gua.Lines[5].六神);

            gua = new Gua("震为雷", "地雷复", HHTime.Parse("/辛丑/甲子/"));
            Assert.IsNotNull(gua);

            Assert.AreEqual("青龙", gua.Lines[0].六神);
            Assert.AreEqual("朱雀", gua.Lines[1].六神);
            Assert.AreEqual("勾陈", gua.Lines[2].六神);
            Assert.AreEqual("螣蛇", gua.Lines[3].六神);
            Assert.AreEqual("白虎", gua.Lines[4].六神);
            Assert.AreEqual("玄武", gua.Lines[5].六神);
        }
Exemple #4
0
        public void 八字调整Test()
        {
            DateTime day  = new DateTime(1978, 7, 1, 6, 45, 0);
            HHTime   ming = new HHTime(day);

            Assert.IsNotNull(ming);

            Assert.AreEqual("戊午", ming.年.Name);
            Assert.AreEqual("戊午", ming.月.Name);
            Assert.AreEqual("甲子", ming.日.Name);
            Assert.AreEqual("丁卯", ming.时.Name);

            HHTime ming1 = new HHTime(day, 确定时辰: false);

            Assert.IsNotNull(ming1);
            Assert.AreEqual("戊午", ming1.年.Name);
            Assert.AreEqual("戊午", ming1.月.Name);
            Assert.AreEqual("甲子", ming1.日.Name);
            Assert.AreEqual("口口", ming1.时.Name);

            // 2017.2.3 晚 23后换月令 所以当天还是
            DateTime old     = new DateTime(2017, 2, 3, 22, 45, 0);
            HHTime   mingOld = new HHTime(old);

            Assert.AreEqual("丙申", mingOld.年.Name);
            Assert.AreEqual("辛丑", mingOld.月.Name);
            Assert.AreEqual("辛酉", mingOld.日.Name);
            Assert.AreEqual("己亥", mingOld.时.Name);

            DateTime lichun     = new DateTime(2017, 2, 3, 23, 45, 0);
            HHTime   mingLiChun = new HHTime(lichun);

            Assert.AreEqual("丁酉", mingLiChun.年.Name);
            Assert.AreEqual("壬寅", mingLiChun.月.Name);
            Assert.AreEqual("壬戌", mingLiChun.日.Name);
            Assert.AreEqual("庚子", mingLiChun.时.Name);

            day  = new DateTime(2017, 2, 2, 7, 45, 0);
            ming = new HHTime(day);
            Assert.AreEqual("丙申", ming.年.Name);
            Assert.AreEqual("辛丑", ming.月.Name);
            Assert.AreEqual("庚申", ming.日.Name);
            Assert.AreEqual("庚辰", ming.时.Name);


            BaZiList <GanZhi> bazi = BaZiList.Create(new GanZhi(""), new GanZhi("卯"), new GanZhi("甲子"), new GanZhi(""));

            ming = new HHTime(bazi);
            Assert.IsNotNull(ming);
            Assert.AreEqual(-1, ming.年.Index);
            Assert.AreEqual(-1, ming.月.Index);
            Assert.AreEqual(0, ming.日.Index);
            Assert.AreEqual("口卯", ming.月.Name);
            Assert.AreEqual("口卯月 甲子日 ", ming.TimeText);
            Assert.AreEqual("/卯/甲子/", ming.ToString());
        }
Exemple #5
0
        public void LineTextTest()
        {
            Gua gua = new Gua("火雷噬嗑", "山天大畜", HHTime.Parse("/寅/辛酉/"));

            Assert.AreEqual("白虎/妻财丑土/父母子水/父母子水//少阳", string.Join("/", gua.Lines[0].Text));
            Assert.AreEqual("玄武/父母亥水/兄弟寅木/兄弟寅木/应/老阴", string.Join("/", gua.Lines[1].Text));
            Assert.AreEqual("青龙/官鬼酉金/妻财辰土/妻财辰土//老阴", string.Join("/", gua.Lines[2].Text));
            Assert.AreEqual("朱雀/妻财未土/官鬼酉金/妻财戌土//老阳", string.Join("/", gua.Lines[3].Text));
            Assert.AreEqual("勾陈/子孙巳火/妻财未土/父母子水/世/少阴", string.Join("/", gua.Lines[4].Text));
            Assert.AreEqual("螣蛇/兄弟卯木/子孙巳火/兄弟寅木//少阳", string.Join("/", gua.Lines[5].Text));

            gua = new Gua("火雷噬嗑", "火雷噬嗑", HHTime.Parse("/寅/辛酉/"));
            Assert.AreEqual("白虎/妻财丑土/父母子水///少阳", string.Join("/", gua.Lines[0].Text));
            Assert.AreEqual("玄武/父母亥水/兄弟寅木//应/少阴", string.Join("/", gua.Lines[1].Text));
            Assert.AreEqual("青龙/官鬼酉金/妻财辰土///少阴", string.Join("/", gua.Lines[2].Text));
            Assert.AreEqual("朱雀/妻财未土/官鬼酉金///少阳", string.Join("/", gua.Lines[3].Text));
            Assert.AreEqual("勾陈/子孙巳火/妻财未土//世/少阴", string.Join("/", gua.Lines[4].Text));
            Assert.AreEqual("螣蛇/兄弟卯木/子孙巳火///少阳", string.Join("/", gua.Lines[5].Text));
        }
Exemple #6
0
        public void Gua神煞Test()
        {
            Gua gua = new Gua("震为雷", "地雷复", HHTime.Parse("/寅/辛酉/"));
            Dictionary <string, string> 神煞 = new Dictionary <string, string>();

            gua.神煞.ForEach(ss => 神煞[ss.Name] = string.Join("", ss.Calc() ?? new string[] { "-" }));
            Assert.AreEqual("酉", 神煞["将星"]);
            Assert.AreEqual("申", 神煞["羊刃"]);
            Assert.AreEqual("酉", 神煞["禄神"]);
            Assert.AreEqual("丑", 神煞["华盖"]);
            Assert.AreEqual("子", 神煞["文昌"]);
            Assert.AreEqual("未", 神煞["谋星"]);
            Assert.AreEqual("戌", 神煞["天喜"]);
            Assert.AreEqual("丑", 神煞["天医"]);
            Assert.AreEqual("亥", 神煞["驿马"]);
            Assert.AreEqual("午", 神煞["桃花"]);
            Assert.AreEqual("卯", 神煞["灾煞"]);
            Assert.AreEqual("寅", 神煞["劫煞"]);
            Assert.AreEqual("寅午", 神煞["贵人"]);
            Assert.AreEqual("子丑", 神煞["旬空"]);
        }
Exemple #7
0
        public void 本爻Test()
        {
            Gua gua = new Gua("火雷噬嗑", "山天大畜", HHTime.Parse("/寅/辛酉/"));

            Assert.AreEqual("父母", gua.Lines[0].本爻.五神);
            Assert.AreEqual("庚子", gua.Lines[0].本爻.干支.Name);
            Assert.AreEqual("", gua.Lines[0].世应);
            Assert.AreEqual(1, gua.本卦.阴阳(0));
            Assert.AreEqual(阴阳.少阳, gua.Lines[0].本爻.阴阳);

            Assert.AreEqual("兄弟", gua.Lines[1].本爻.五神);
            Assert.AreEqual("庚寅", gua.Lines[1].本爻.干支.Name);
            Assert.AreEqual("应", gua.Lines[1].世应);
            Assert.AreEqual(0, gua.本卦.阴阳(1));
            Assert.AreEqual(阴阳.老阴, gua.Lines[1].本爻.阴阳);

            Assert.AreEqual("妻财", gua.Lines[2].本爻.五神);
            Assert.AreEqual("庚辰", gua.Lines[2].本爻.干支.Name);
            Assert.AreEqual("", gua.Lines[2].世应);
            Assert.AreEqual(0, gua.本卦.阴阳(2));
            Assert.AreEqual(阴阳.老阴, gua.Lines[2].本爻.阴阳);

            Assert.AreEqual("官鬼", gua.Lines[3].本爻.五神);
            Assert.AreEqual("己酉", gua.Lines[3].本爻.干支.Name);
            Assert.AreEqual("", gua.Lines[3].世应);
            Assert.AreEqual(1, gua.本卦.阴阳(3));
            Assert.AreEqual(阴阳.老阳, gua.Lines[3].本爻.阴阳);

            Assert.AreEqual("妻财", gua.Lines[4].本爻.五神);
            Assert.AreEqual("己未", gua.Lines[4].本爻.干支.Name);
            Assert.AreEqual("世", gua.Lines[4].世应);
            Assert.AreEqual(0, gua.本卦.阴阳(4));
            Assert.AreEqual(阴阳.少阴, gua.Lines[4].本爻.阴阳);

            Assert.AreEqual("子孙", gua.Lines[5].本爻.五神);
            Assert.AreEqual("己巳", gua.Lines[5].本爻.干支.Name);
            Assert.AreEqual("", gua.Lines[5].世应);
            Assert.AreEqual(1, gua.本卦.阴阳(5));
            Assert.AreEqual(阴阳.少阳, gua.Lines[5].本爻.阴阳);
        }
Exemple #8
0
        public void 构造函数Test()
        {
            HHTime time = new HHTime(new DateTime(1978, 7, 1, 6, 45, 0));

            Assert.IsNotNull(time);
            Assert.AreEqual(HHTime.TimeType.时间, time.Type);
            Assert.AreEqual("戊午", time.年.Name);
            Assert.AreEqual("戊午", time.月.Name);
            Assert.AreEqual("甲子", time.日.Name);
            Assert.AreEqual("丁卯", time.时.Name);
            Assert.AreEqual("五月廿六", time.农历);

            Assert.AreEqual("1978年7月1日 6时45分", time.TimeText);
            Assert.AreNotEqual(new DateTime(), time.DateTime);

            BaZiList <GanZhi> bazi = BaZiList.Create(new GanZhi("戊午"), new GanZhi("戊午"), new GanZhi("甲子"), new GanZhi("丁卯"));

            time = new HHTime(bazi);
            Assert.AreEqual(HHTime.TimeType.干支, time.Type);
            Assert.AreEqual("戊午年 戊午月 甲子日 丁卯时", time.TimeText);

            Assert.AreEqual(new DateTime(), time.DateTime);
        }
Exemple #9
0
        public void ParseMethodeTest()
        {
            DateTime day  = new DateTime(1978, 7, 1, 6, 45, 0);
            string   text = day.ToString();

            HHTime time = HHTime.Parse(text);

            Assert.IsNotNull(time);
            Assert.AreEqual(text, time.ToString());

            time = HHTime.Parse(text, 确定时辰: false);
            Assert.IsNotNull(time);
            Assert.AreEqual(day.ToShortDateString(), time.ToString());

            BaZiList <GanZhi> bazi = BaZiList.Create(new GanZhi(""), new GanZhi("卯"), new GanZhi("甲子"), new GanZhi(""));

            Assert.AreEqual("/卯/甲子/", bazi.ToString());
            time = HHTime.Parse(bazi.ToString());
            Assert.AreEqual(bazi.ToString(), time.ToString());

            time = HHTime.Parse("//丁卯/");
            Assert.AreEqual("//丁卯/", time.ToString());
        }