Example #1
0
        /// <summary>
        /// Gets the Chinese zodiac element based on the year.
        /// This is different from the fixed element which is
        /// strongly associated with one or more zodiac sign.
        /// </summary>
        /// <param name="year">The year you want the zodiac element for.</param>
        /// <returns>The Chinese zodiac element for the supplied year.</returns>
        public static ChineseZodiacElements GetChineseZodiacElementBasedOnYear(int year)
        {
            int lastDigitOfYear = ChineseZodiacHelper.GetRightMostDigitOfYear(year);

            if (lastDigitOfYear == 0 || lastDigitOfYear == 1)
            {
                return(ChineseZodiacElements.Metal);
            }
            else if (lastDigitOfYear == 2 || lastDigitOfYear == 3)
            {
                return(ChineseZodiacElements.Water);
            }
            else if (lastDigitOfYear == 4 || lastDigitOfYear == 5)
            {
                return(ChineseZodiacElements.Wood);
            }
            else if (lastDigitOfYear == 6 || lastDigitOfYear == 7)
            {
                return(ChineseZodiacElements.Fire);
            }
            else
            {
                return(ChineseZodiacElements.Earth);
            }
        }
Example #2
0
        public void GetRightMostDigitOfYear_Test(int year, int expected)
        {
            var lastDigit = ChineseZodiacHelper.GetRightMostDigitOfYear(year);

            Assert.Equal(expected, lastDigit);
        }