public LeagueOptions(int standardGames, int gamesToDraft, int counterPicks, int counterPicksToDraft, int freeDroppableGames, int willNotReleaseDroppableGames, int willReleaseDroppableGames, bool dropOnlyDraftGames, bool counterPicksBlockDrops, int minimumBidAmount, IEnumerable <LeagueTagStatus> leagueTags, IEnumerable <SpecialGameSlot> specialGameSlots, DraftSystem draftSystem, PickupSystem pickupSystem, ScoringSystem scoringSystem, TradingSystem tradingSystem, TiebreakSystem tiebreakSystem, AnnualDate counterPickDeadline) { StandardGames = standardGames; GamesToDraft = gamesToDraft; CounterPicks = counterPicks; CounterPicksToDraft = counterPicksToDraft; FreeDroppableGames = freeDroppableGames; WillNotReleaseDroppableGames = willNotReleaseDroppableGames; WillReleaseDroppableGames = willReleaseDroppableGames; DropOnlyDraftGames = dropOnlyDraftGames; CounterPicksBlockDrops = counterPicksBlockDrops; MinimumBidAmount = minimumBidAmount; LeagueTags = leagueTags.ToList(); SpecialGameSlots = specialGameSlots.OrderBy(x => x.SpecialSlotPosition).ToList(); DraftSystem = draftSystem; PickupSystem = pickupSystem; ScoringSystem = scoringSystem; TradingSystem = tradingSystem; TiebreakSystem = tiebreakSystem; CounterPickDeadline = counterPickDeadline; _specialSlotDictionary = SpecialGameSlots.ToDictionary(specialGameSlot => StandardGames - SpecialGameSlots.Count + specialGameSlot.SpecialSlotPosition); }
public void AnnualDateConverter() { var value = new AnnualDate(12, 5); string json = "12-05"; AssertConversions(value, json, NodaSerializerDefinitions.AnnualDateSerializer); }
public LeagueYearParameters(Guid leagueID, int year, int standardGames, int gamesToDraft, int counterPicks, int counterPicksToDraft, int freeDroppableGames, int willNotReleaseDroppableGames, int willReleaseDroppableGames, bool dropOnlyDraftGames, bool counterPicksBlockDrops, int minimumBidAmount, IEnumerable <LeagueTagStatus> leagueTags, IEnumerable <SpecialGameSlot> specialGameSlots, DraftSystem draftSystem, PickupSystem pickupSystem, ScoringSystem scoringSystem, TradingSystem tradingSystem, TiebreakSystem tiebreakSystem, AnnualDate counterPickDeadline) { LeagueID = leagueID; Year = year; StandardGames = standardGames; GamesToDraft = gamesToDraft; CounterPicks = counterPicks; CounterPicksToDraft = counterPicksToDraft; FreeDroppableGames = freeDroppableGames; WillNotReleaseDroppableGames = willNotReleaseDroppableGames; WillReleaseDroppableGames = willReleaseDroppableGames; DropOnlyDraftGames = dropOnlyDraftGames; CounterPicksBlockDrops = counterPicksBlockDrops; MinimumBidAmount = minimumBidAmount; LeagueTags = leagueTags.ToList(); SpecialGameSlots = specialGameSlots.ToList(); DraftSystem = draftSystem; PickupSystem = pickupSystem; ScoringSystem = scoringSystem; TradingSystem = tradingSystem; TiebreakSystem = tiebreakSystem; CounterPickDeadline = counterPickDeadline; }
public void InYear() { var annualDate = new AnnualDate(3, 12); var localDate = Snippet.For(annualDate.InYear(2013)); Assert.AreEqual(new LocalDate(2013, 3, 12), localDate); }
public void Deserialize_ToNullableType_NonNullValue() { string json = "\"07-01\""; var annualDate = JsonConvert.DeserializeObject <AnnualDate?>(json, settings); AnnualDate?expectedAnnualDate = new AnnualDate(07, 01); Assert.AreEqual(expectedAnnualDate, annualDate); }
public void Deserialize_ToNullableType_NonNullValue() { string json = "\"07-01\""; var annualDate = JsonSerializer.Deserialize <AnnualDate?>(json, options); AnnualDate?expectedAnnualDate = new AnnualDate(07, 01); Assert.AreEqual(expectedAnnualDate, annualDate); }
public void Serialize_NullableType_NonNullValue() { AnnualDate?annualDate = new AnnualDate(07, 01); var json = JsonSerializer.Serialize(annualDate, options); string expectedJson = "\"07-01\""; Assert.AreEqual(expectedJson, json); }
public void Serialize_NullableType_NonNullValue() { AnnualDate?annualDate = new AnnualDate(07, 01); var json = JsonConvert.SerializeObject(annualDate, Formatting.None, settings); string expectedJson = "\"07-01\""; Assert.AreEqual(expectedJson, json); }
public void June19() { var date = new AnnualDate(6, 19); Assert.AreEqual(19, date.Day); Assert.AreEqual(6, date.Month); Assert.AreEqual(new LocalDate(2016, 6, 19), date.InYear(2016)); Assert.IsTrue(date.IsValidYear(2016)); Assert.AreEqual(new LocalDate(2015, 6, 19), date.InYear(2015)); Assert.IsTrue(date.IsValidYear(2015)); }
public void Feb29() { var date = new AnnualDate(2, 29); Assert.AreEqual(29, date.Day); Assert.AreEqual(2, date.Month); Assert.AreEqual(new LocalDate(2016, 2, 29), date.InYear(2016)); Assert.IsTrue(date.IsValidYear(2016)); Assert.AreEqual(new LocalDate(2015, 2, 28), date.InYear(2015)); Assert.IsFalse(date.IsValidYear(2015)); }
public void IsValidYear() { var leapDay = new AnnualDate(2, 29); var leapYear = Snippet.For(leapDay.IsValidYear(2020)); var nonLeapYear = leapDay.IsValidYear(2018); Assert.True(leapYear); Assert.False(nonLeapYear); }
public void June19() { var date = new AnnualDate(6, 19); Assert.AreEqual(19, date.Day); Assert.AreEqual(6, date.Month); Assert.AreEqual(new LocalDate(2016, 6, 19), date.InYear(2016)); Assert.IsTrue(date.IsValidYear(2016)); Assert.AreEqual(new LocalDate(2015, 6, 19), date.InYear(2015)); Assert.IsTrue(date.IsValidYear(2015)); }
public void Feb29() { var date = new AnnualDate(2, 29); Assert.AreEqual(29, date.Day); Assert.AreEqual(2, date.Month); Assert.AreEqual(new LocalDate(2016, 2, 29), date.InYear(2016)); Assert.IsTrue(date.IsValidYear(2016)); Assert.AreEqual(new LocalDate(2015, 2, 28), date.InYear(2015)); Assert.IsFalse(date.IsValidYear(2015)); }
public void Equals() { var february23rd = new AnnualDate(2, 23); var august17th = new AnnualDate(8, 17); var unequal = Snippet.For(february23rd.Equals(august17th)); var equal = february23rd.Equals(february23rd); Assert.False(unequal); Assert.True(equal); }
public void IsOnAnnualDate_Feb28OnLeapYear() { // Arrange var date = new LocalDate(2020, 02, 28); var annualDate = new AnnualDate(02, 29); // Act var isOnAnnualDate = date.IsOnAnnualDate(annualDate); // Assert isOnAnnualDate.Should().BeFalse(); }
/// <summary> /// Returns this annual date in the same year as <paramref name="fromDate"/>, unless that date is before <paramref name="fromDate"/>, /// then in the next year. /// </summary> /// <param name="annualDate">An annual date.</param> /// <param name="fromDate">The reference date from which the next occurrence should be found.</param> /// <returns>The next occurrence of the annual date.</returns> /// <remarks> /// <para> /// If the annual date is the same day as <paramref name="fromDate"/>, that date is returned. /// </para> /// <para> /// As with <see cref="AnnualDate.IsValidYear"/>, if the annual date represents February 29th, and the next occurrence is not in a leap year, /// the returned value will be February 28th of that year. /// </para> /// </remarks> public static LocalDate NextOccurrence(this AnnualDate annualDate, LocalDate fromDate) { var date = annualDate.InYear(fromDate.Year); // If the date already passed, go to the next year if (date < fromDate) { date = annualDate.InYear(fromDate.Year + 1); } return(date); }
public void CompareTo() { var february23rd = new AnnualDate(2, 23); var august17th = new AnnualDate(8, 17); var lessThan = Snippet.For(february23rd.CompareTo(august17th)); var equal = february23rd.CompareTo(february23rd); var greaterThan = august17th.CompareTo(february23rd); Assert.Less(lessThan, 0); Assert.AreEqual(0, equal); Assert.Greater(greaterThan, 0); }
public LeagueYear ToDomain(League league, SupportedYear year, IEnumerable <EligibilityOverride> eligibilityOverrides, IEnumerable <TagOverride> tagOverrides, IEnumerable <LeagueTagStatus> leagueTags, IEnumerable <SpecialGameSlot> specialGameSlots, FantasyCriticUser?winningUser, IEnumerable <Publisher> publishersInLeague) { DraftSystem draftSystem = Lib.Enums.DraftSystem.FromValue(DraftSystem); PickupSystem pickupSystem = Lib.Enums.PickupSystem.FromValue(PickupSystem); TradingSystem tradingSystem = Lib.Enums.TradingSystem.FromValue(TradingSystem); TiebreakSystem tiebreakSystem = Lib.Enums.TiebreakSystem.FromValue(TiebreakSystem); ScoringSystem scoringSystem = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem); AnnualDate counterPickDeadline = new AnnualDate(CounterPickDeadlineMonth, CounterPickDeadlineDay); LeagueOptions options = new LeagueOptions(StandardGames, GamesToDraft, CounterPicks, CounterPicksToDraft, FreeDroppableGames, WillNotReleaseDroppableGames, WillReleaseDroppableGames, DropOnlyDraftGames, CounterPicksBlockDrops, MinimumBidAmount, leagueTags, specialGameSlots, draftSystem, pickupSystem, scoringSystem, tradingSystem, tiebreakSystem, counterPickDeadline); return(new LeagueYear(league, year, options, Lib.Enums.PlayStatus.FromValue(PlayStatus), eligibilityOverrides, tagOverrides, DraftStartedTimestamp, winningUser, publishersInLeague)); }
public LeagueYearParameters ToDomain(IReadOnlyDictionary <string, MasterGameTag> tagDictionary) { DraftSystem draftSystem = Lib.Enums.DraftSystem.FromValue(DraftSystem); PickupSystem pickupSystem = Lib.Enums.PickupSystem.FromValue(PickupSystem); TradingSystem tradingSystem = Lib.Enums.TradingSystem.FromValue(TradingSystem); TiebreakSystem tiebreakSystem = Lib.Enums.TiebreakSystem.FromValue(TiebreakSystem); ScoringSystem scoringSystem = Lib.Domain.ScoringSystems.ScoringSystem.GetScoringSystem(ScoringSystem); int freeDroppableGames = FreeDroppableGames; if (UnlimitedFreeDroppableGames) { freeDroppableGames = -1; } int willNotReleaseDroppableGames = WillNotReleaseDroppableGames; if (UnlimitedWillNotReleaseDroppableGames) { willNotReleaseDroppableGames = -1; } int willReleaseDroppableGames = WillReleaseDroppableGames; if (UnlimitedWillReleaseDroppableGames) { willReleaseDroppableGames = -1; } var counterPickDeadline = new AnnualDate(CounterPickDeadline.Month, CounterPickDeadline.Day); var leagueTags = Tags.ToDomain(tagDictionary); var specialGameSlots = SpecialGameSlots.Select(x => x.ToDomain(tagDictionary)); LeagueYearParameters parameters = new LeagueYearParameters(LeagueID, Year, StandardGames, GamesToDraft, CounterPicks, CounterPicksToDraft, freeDroppableGames, willNotReleaseDroppableGames, willReleaseDroppableGames, DropOnlyDraftGames, CounterPicksBlockDrops, MinimumBidAmount, leagueTags, specialGameSlots, draftSystem, pickupSystem, scoringSystem, tradingSystem, tiebreakSystem, counterPickDeadline); return(parameters); }
public void XmlSerialization() { AnnualDate value = new AnnualDate(3, 14); TestHelper.AssertXmlRoundtrip(value, "<value>03-14</value>"); }
/// <summary> /// Determines whether the local date is on the annual date, i.e. whether the months and days are equal. /// </summary> /// <remarks> /// <para> /// If the annual date represents February 29th, and the specified date represents February 28th in a non-leap /// year, the returned value will be <c>true</c>; if it is a leap year, only a date representing February 29th /// will return <c>true</c>. /// </para> /// </remarks> /// <param name="date">The local date.</param> /// <param name="annualDate">The annual date.</param> /// <returns><c>true</c>, if the date is on the annual date; <c>false</c>, otherwise.</returns> public static bool IsOnAnnualDate(this LocalDate date, AnnualDate annualDate) => annualDate.InYear(date.Year) == date;
protected override DateTime Wrap(AnnualDate value) => value.InYear(_baseYear).ToDateTimeUnspecified();