public void ParsesKeyProperly() { const string input = "Equity-usa-SPY"; var key = SecurityDatabaseKey.Parse(input); Assert.AreEqual(SecurityType.Equity, key.SecurityType); Assert.AreEqual(Market.USA, key.Market); Assert.AreEqual("SPY", key.Symbol); }
public void ParsesWildcardMarket() { const string input = "Equity-[*]-SPY"; var key = SecurityDatabaseKey.Parse(input); Assert.AreEqual(SecurityType.Equity, key.SecurityType); Assert.AreEqual("[*]", key.Market); Assert.AreEqual("SPY", key.Symbol); }
public void ThrowsOnInvalidFormat() { const string input = "Equity-[*]"; Assert.Throws <FormatException>(() => { SecurityDatabaseKey.Parse(input); }, "expected format"); }
public void ThrowsOnWildcardSecurityType() { const string input = "[*]-usa-SPY"; Assert.Throws <ArgumentException>(() => { SecurityDatabaseKey.Parse(input); }, "as a SecurityType"); }
/// <summary> /// Converts this json representation to the <see cref="MarketHoursDatabase"/> type /// </summary> /// <returns>A new instance of the <see cref="MarketHoursDatabase"/> class</returns> public MarketHoursDatabase Convert() { var entries = new Dictionary <SecurityDatabaseKey, MarketHoursDatabase.Entry>(); foreach (var entry in Entries) { try { var key = SecurityDatabaseKey.Parse(entry.Key); entries[key] = entry.Value.Convert(); } catch (Exception err) { Log.Error(err); } } return(new MarketHoursDatabase(entries)); }
public void ThrowsOnInvalidFormat() { const string input = "Equity-[*]"; SecurityDatabaseKey.Parse(input); }
public void ThrowsOnWildcardSecurityType() { const string input = "[*]-usa-SPY"; SecurityDatabaseKey.Parse(input); }
public void DoesNotThrowOnUnknownSecurityType(string key) { Assert.DoesNotThrow(() => SecurityDatabaseKey.Parse(key)); }