private static Indicator CreateIndicator(IDictionary <string, string> properties, IDictionary <string, PropertyDescription> descriptions) { return(Indicator.Create( ticker, properties is null ? PropertyDictionary.Empty() : new PropertyDictionary(properties), descriptions is null ? PropertyDescriptionDictionary.Empty() : new PropertyDescriptionDictionary(descriptions) )); }
private static Quarter CreateQuarter(string ticker, FiscalQuarterPeriod period, IDictionary <string, string> properties, IDictionary <string, PropertyDescription> descriptions) { return(Quarter.Create( ticker, period, properties is null ? PropertyDictionary.Empty() : new PropertyDictionary(properties), descriptions is null ? PropertyDescriptionDictionary.Empty() : new PropertyDescriptionDictionary(descriptions) )); }
public void GetHashCodeTest() { var a = new PropertyDictionary(properties).GetHashCode(); var b = new PropertyDictionary(properties).GetHashCode(); var c = PropertyDictionary.Empty().GetHashCode(); Assert.AreEqual(a, b); Assert.AreNotEqual(a, c); }
private static Daily CreateDaily(string ticker, DayPeriod period, IDictionary <string, string> properties, IDictionary <string, PropertyDescription> descriptions) { return(Daily.Create( ticker, period, properties is null ? PropertyDictionary.Empty() : new PropertyDictionary(properties), descriptions is null ? PropertyDescriptionDictionary.Empty() : new PropertyDescriptionDictionary(descriptions) )); }
public void EqualsTest() { var a = new PropertyDictionary(properties); var b = new PropertyDictionary(properties); var c = PropertyDictionary.Empty(); Assert.AreEqual(a, b); Assert.AreNotEqual(a, c); Assert.AreNotEqual(a, null); }
public void EmptyTest() { var empty = PropertyDictionary.Empty(); Assert.AreEqual(0, empty.Count); }
public void GetDayTest() { var company = Company.Create(ticker, fixedTierQuarterRange, ondemandTierQuarterRange, fixedTierDayRange, ondemandTierDayRange, PropertyDictionary.Empty(), PropertyDescriptionDictionary.Empty()); var dict = new SupportedTierDictionary <DayPeriod>(); // throw Key NotFound Assert.ThrowsException <KeyNotFoundException>(() => dict.Get(ticker, fixedTierLatestDay)); // day Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, ondemandLatestDay)); Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, fixedTierLatestDay)); Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, fixedTierOldestDay)); Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, (DayPeriod)fixedTierOldestDay.Next())); Assert.AreEqual(SupportedTier.OndemandTier, dict.Get(ticker, (DayPeriod)fixedTierOldestDay.Prev())); Assert.AreEqual(SupportedTier.OndemandTier, dict.Get(ticker, ondemandOldestDay)); Assert.AreEqual(SupportedTier.OndemandTier, dict.Get(ticker, (DayPeriod)ondemandOldestDay.Next())); Assert.AreEqual(SupportedTier.None, dict.Get(ticker, (DayPeriod)ondemandOldestDay.Prev())); Assert.AreEqual(SupportedTier.None, dict.Get(ticker, (DayPeriod)fixedTierLatestDay.Next())); Assert.AreEqual(SupportedTier.None, dict.Get(ticker, (DayPeriod)ondemandLatestDay.Next())); }
public void GetQuarterTest() { var company = Company.Create(ticker, fixedTierQuarterRange, ondemandTierQuarterRange, fixedTierDayRange, ondemandTierDayRange, PropertyDictionary.Empty(), PropertyDescriptionDictionary.Empty()); var dict = new SupportedTierDictionary <FiscalQuarterPeriod>(); // throw Key NotFound Assert.ThrowsException <KeyNotFoundException>(() => dict.Get(ticker, fixedLatestQuarter)); dict.Add(company.Ticker, company.SupportedQuarterRanges); // quarter Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, fixedOldestQuarter)); Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, (FiscalQuarterPeriod)fixedOldestQuarter.Next())); Assert.AreEqual(SupportedTier.FixedTier, dict.Get(ticker, fixedLatestQuarter)); Assert.AreEqual(SupportedTier.OndemandTier, dict.Get(ticker, ondemandOldestQuarter)); Assert.AreEqual(SupportedTier.OndemandTier, dict.Get(ticker, (FiscalQuarterPeriod)ondemandOldestQuarter.Next())); Assert.AreEqual(SupportedTier.OndemandTier, dict.Get(ticker, ondemandLatestQuarter)); Assert.AreEqual(SupportedTier.None, dict.Get(ticker, (FiscalQuarterPeriod)ondemandLatestQuarter.Next())); }
public void AddAndHasTest() { var dict = new SupportedTierDictionary <FiscalQuarterPeriod>(); var company = Company.Create(ticker, fixedTierQuarterRange, ondemandTierQuarterRange, fixedTierDayRange, ondemandTierDayRange, PropertyDictionary.Empty(), PropertyDescriptionDictionary.Empty()); // at first, not contained Assert.IsFalse(dict.Has(ticker)); dict.Add(company.Ticker, company.SupportedQuarterRanges); // check added Assert.IsTrue(dict.Has(ticker)); }