Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void ThrowsOnInvalidFormat()
        {
            const string input = "Equity-[*]";

            Assert.Throws <FormatException>(() =>
            {
                SecurityDatabaseKey.Parse(input);
            }, "expected format");
        }
Exemplo n.º 4
0
        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));
            }
Exemplo n.º 6
0
        public void ThrowsOnInvalidFormat()
        {
            const string input = "Equity-[*]";

            SecurityDatabaseKey.Parse(input);
        }
Exemplo n.º 7
0
        public void ThrowsOnWildcardSecurityType()
        {
            const string input = "[*]-usa-SPY";

            SecurityDatabaseKey.Parse(input);
        }
Exemplo n.º 8
0
 public void DoesNotThrowOnUnknownSecurityType(string key)
 {
     Assert.DoesNotThrow(() => SecurityDatabaseKey.Parse(key));
 }