Exemple #1
0
        public void CommodityPool_CommodityQuoteFromScript_SetsNoMarkedFlagInCaseOfFailure()
        {
            Commodity commodity1 = CommodityPool.Current.Create("QUO1"); commodity1.QualifiedSymbol = "QUO1";

            TestQuoteProvider quoteProvider = new TestQuoteProvider()
            {
                ResultGet = false
            };

            MainApplicationContext.Current.SetQuoteProvider(() => quoteProvider);

            var result = CommodityPool.CommodityQuoteFromScript(commodity1, null);

            Assert.IsNull(result);
            Assert.IsTrue(commodity1.Flags.HasFlag(CommodityFlagsEnum.COMMODITY_NOMARKET));
        }
Exemple #2
0
        public void CommodityPool_CommodityQuoteFromScript_ReturnsPricePointInCaseOfSuccess()
        {
            Commodity commodity1 = CommodityPool.Current.Create("QUO1");
            Commodity commodity2 = CommodityPool.Current.Create("QUO2");

            TestQuoteProvider quoteProvider = new TestQuoteProvider()
            {
                ResultGet = true, ResultResponse = "2010/10/10 10:11:12 AAPL $100.00"
            };

            MainApplicationContext.Current.SetQuoteProvider(() => quoteProvider);

            var result = CommodityPool.CommodityQuoteFromScript(commodity1, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(new DateTime(2010, 10, 10, 10, 11, 12), result.Value.When);
            Assert.AreEqual("$100", result.Value.Price.ToString());
        }
Exemple #3
0
        public void CommodityPool_CommodityQuoteFromScript_AddsCommoditiesToCommand()
        {
            Commodity commodity1 = CommodityPool.Current.Create("QUO1"); commodity1.QualifiedSymbol = "QUO1";
            Commodity commodity2 = CommodityPool.Current.Create("QUO2"); commodity2.QualifiedSymbol = "QUO2";

            TestQuoteProvider quoteProvider = new TestQuoteProvider()
            {
                ResultGet = true, ResultResponse = String.Empty
            };

            MainApplicationContext.Current.SetQuoteProvider(() => quoteProvider);

            CommodityPool.CommodityQuoteFromScript(commodity1, null);
            Assert.AreEqual("getquote \"QUO1\" \"\"", quoteProvider.ReceivedCommand);

            CommodityPool.CommodityQuoteFromScript(commodity1, commodity2);
            Assert.AreEqual("getquote \"QUO1\" \"QUO2\"", quoteProvider.ReceivedCommand);
        }