-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using Horoscope.Extensions; | ||
using Xunit; | ||
|
||
namespace Horoscope.Tests | ||
{ | ||
public class DateTimeExtensionsTest | ||
{ | ||
[Theory] | ||
[InlineData(2, 12, "Aquarius")] | ||
[InlineData(3, 3, "Pisces")] | ||
[InlineData(2, 28, "Pisces")] | ||
[InlineData(10, 23, "Scorpio")] | ||
public void GetZodiacSign_Test(int month, int day, string zodiacSign) | ||
{ | ||
var dateTime = new DateTime(1950, month, day); | ||
var symbol = dateTime.GetZodiacSign(); | ||
Assert.Equal(zodiacSign, symbol.ZodiacName); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2018, "Dog")] | ||
[InlineData(1952, "Dragon")] | ||
[InlineData(1969, "Rooster")] | ||
[InlineData(1903, "Rabbit")] | ||
public void GetChineseZodiacSign_Test(int year, string zodiacSign) | ||
{ | ||
var dateTime = new DateTime(year, 4, 1); | ||
var symbol = dateTime.GetChineseZodiacSign(); | ||
Assert.Equal(zodiacSign, symbol.ZodiacEnglishTranslation); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Horoscope.Model; | ||
using System; | ||
|
||
namespace Horoscope | ||
{ | ||
/// <summary> | ||
/// Enable usage of Zodiac and ChineseZodiac methods straight from DateTime instances | ||
/// </summary> | ||
public static class DateTimeExtensions | ||
{ | ||
/// <summary> | ||
/// Gets the zodiac sign. | ||
/// </summary> | ||
/// <param name="dateTime">The date for which you want the zodiac sign.</param> | ||
/// <returns>A zodiac sign object.</returns> | ||
public static ZodiacModel GetZodiacSign(this DateTime dateTime) => Zodiac.GetZodiacSignForDate(dateTime); | ||
|
||
/// <summary> | ||
/// Get the Chinese zodiac sign. | ||
/// </summary> | ||
/// <param name="dateTime">The date you want to query.</param> | ||
/// <returns>Returns a Chinese zodiac sign object.</returns> | ||
public static ChineseZodiacModel GetChineseZodiacSign(this DateTime dateTime) => ChineseZodiac.GetZodiacSignForDate(dateTime); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Horoscope.Model; | ||
using System; | ||
|
||
namespace Horoscope.Extensions | ||
{ | ||
public static class DateTimeExtensions | ||
{ | ||
/// <summary> | ||
/// Gets the zodiac sign for the date supplied. | ||
/// </summary> | ||
/// <param name="dateTime">The date for which you want the zodiac sign.</param> | ||
/// <returns>A zodiac sign object.</returns> | ||
public static ZodiacModel GetZodiacSign(this DateTime dateTime) => Zodiac.GetZodiacSignForDate(dateTime); | ||
|
||
/// <summary> | ||
/// Get the Chinese zodiac sign for the supplied date. | ||
/// </summary> | ||
/// <param name="dateTime">The date you want to query.</param> | ||
/// <returns>Returns a Chinese zodiac sign object.</returns> | ||
public static ChineseZodiacModel GetChineseZodiacSign(this DateTime dateTime) => ChineseZodiac.GetZodiacSignForDate(dateTime); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters