public void testXiaoYun() { Solar solar = new Solar(1983, 2, 15, 20, 0, 0); Lunar lunar = solar.getLunar(); EightChar bazi = lunar.getEightChar(); Yun yun = bazi.getYun(0); DaYun[] daYun = yun.getDaYun(); int[] years = { 1983, 1984, 1985, 1986, 1987, 1988 }; int[] ages = { 1, 2, 3, 4, 5, 6 }; String[] ganZhi = { "乙亥", "丙子", "丁丑", "戊寅", "己卯", "庚辰" }; XiaoYun[] l = daYun[0].getXiaoYun(); for (int i = 0, j = l.Length; i < j; i++) { XiaoYun xiaoYun = l[i]; Assert.AreEqual(years[i], xiaoYun.getYear()); Assert.AreEqual(ages[i], xiaoYun.getAge()); Assert.AreEqual(ganZhi[i], xiaoYun.getGanZhi()); } years = new int[] { 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038 }; ages = new int[] { 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 }; ganZhi = new String[] { "辛酉", "壬戌", "癸亥", "甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己巳", "庚午" }; l = daYun[5].getXiaoYun(); for (int i = 0, j = l.Length; i < j; i++) { XiaoYun xiaoYun = l[i]; Assert.AreEqual(years[i], xiaoYun.getYear()); Assert.AreEqual(ages[i], xiaoYun.getAge()); Assert.AreEqual(ganZhi[i], xiaoYun.getGanZhi(), years[i] + "年"); } }
public void testLiuYue() { Solar solar = new Solar(1983, 2, 15, 20, 0, 0); Lunar lunar = solar.getLunar(); EightChar bazi = lunar.getEightChar(); Yun yun = bazi.getYun(0); DaYun[] daYun = yun.getDaYun(); String[] ganZhi = { "甲寅", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥", "甲子", "乙丑" }; LiuNian[] liuNian = daYun[0].getLiuNian(); LiuYue[] l = liuNian[0].getLiuYue(); for (int i = 0, j = l.Length; i < j; i++) { LiuYue liuYue = l[i]; Assert.AreEqual(ganZhi[i], liuYue.getGanZhi()); } ganZhi = new String[] { "庚寅", "辛卯", "壬辰", "癸巳", "甲午", "乙未", "丙申", "丁酉", "戊戌", "己亥", "庚子", "辛丑" }; liuNian = daYun[4].getLiuNian(); l = liuNian[2].getLiuYue(); for (int i = 0, j = l.Length; i < j; i++) { LiuYue liuYue = l[i]; Assert.AreEqual(ganZhi[i], liuYue.getGanZhi()); } }
public void testDaYun() { int[] startYears = { 1983, 1989, 1999, 2009, 2019, 2029, 2039, 2049, 2059, 2069 }; int[] endYears = { 1988, 1998, 2008, 2018, 2028, 2038, 2048, 2058, 2068, 2078 }; int[] startAges = { 1, 7, 17, 27, 37, 47, 57, 67, 77, 87 }; int[] endAges = { 6, 16, 26, 36, 46, 56, 66, 76, 86, 96 }; String[] yearGanZhi = { "", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥" }; Solar solar = new Solar(1983, 2, 15, 20, 0, 0); Lunar lunar = solar.getLunar(); EightChar bazi = lunar.getEightChar(); Yun yun = bazi.getYun(0); DaYun[] l = yun.getDaYun(); for (int i = 0, j = l.Length; i < j; i++) { DaYun daYun = l[i]; Assert.AreEqual(startYears[i], daYun.getStartYear()); Assert.AreEqual(endYears[i], daYun.getEndYear()); Assert.AreEqual(startAges[i], daYun.getStartAge()); Assert.AreEqual(endAges[i], daYun.getEndAge()); Assert.AreEqual(yearGanZhi[i], daYun.getGanZhi()); } }