コード例 #1
0
ファイル: TestBasket.cs プロジェクト: bluejack2000/core
 public void BasketBasics()
 {
     BasketImpl mb = new BasketImpl();
     
     Assert.That(mb != null);
     SecurityImpl i = new SecurityImpl("IBM");
     mb = new BasketImpl(i);
     mb.SendDebugEvent += new DebugDelegate(rt.d);
     Assert.That(mb.isNotEmpty);
     Assert.That(mb.isSecurityPresent(i), "missing ibm security");
     Assert.That(mb.isSymbolPresent("IBM"), "missing ibm symbol");
     Assert.IsFalse(mb.isSymbolPresent("LVS"), "had lvs before added");
     mb.Remove(i);
     Assert.That(!mb.isNotEmpty);
     mb.Add(new SecurityImpl("LVS"));
     Assert.That(mb[0].symbol=="LVS",mb[0].ToString());
     mb.Add(new SecurityImpl("IBM"));
     Assert.That(mb[1].symbol=="IBM");
     mb.Add("CLV8 FUT NYMEX");
     Assert.AreEqual(3, mb.Count,"missing futures symbol");
     Assert.IsTrue(mb[1].Type == SecurityType.STK, "not a equities type:" + mb[1].Type);
     Assert.IsTrue(mb[2].Type == SecurityType.FUT, "not a futures type:"+mb[2].Type);
     Security ts;
     Assert.IsTrue(mb.TryGetSecurityAnySymbol("IBM", out ts), "ibm fetch failed");
     Assert.IsTrue(mb.TryGetSecurityAnySymbol("LVS", out ts), "lvs fetch failed");
     Assert.IsTrue(mb.TryGetSecurityAnySymbol("CLV8", out ts), "CLV8 short fetch failed");
     Assert.IsTrue(mb.TryGetSecurityAnySymbol("CLV8 NYMEX FUT", out ts), "CLV8 short fetch failed");
     BasketImpl newbasket = new BasketImpl(new SecurityImpl("FDX"));
     newbasket.Add(mb);
     var orgcount = mb.Count;
     mb.Clear();
     Assert.That(mb.Count==0,"basket clear did not work");
     Assert.AreEqual(orgcount+1,newbasket.Count,"new basket missing symbols");
 }
コード例 #2
0
ファイル: TestBasket.cs プロジェクト: antonywu/tradelink
        public void Serialization()
        {
            BasketImpl mb = new BasketImpl();
            mb.Add(new SecurityImpl("IBM"));
            BasketImpl compare = BasketImpl.Deserialize(mb.ToString());
            Assert.That(compare.Count == 1);
            mb.Clear();
            compare = BasketImpl.Deserialize(mb.ToString());
            Assert.That(compare.Count==0);

            mb.Clear();
            SecurityImpl longform = SecurityImpl.Parse("CLZ8 FUT NYMEX");
            mb.Add(longform);
            compare = BasketImpl.Deserialize(mb.ToString());
            Assert.AreEqual(longform.ToString(),compare[0].ToString());



        }
コード例 #3
0
ファイル: TestBasket.cs プロジェクト: antonywu/tradelink
 public void BasketBasics()
 {
     BasketImpl mb = new BasketImpl();
     Assert.That(mb != null);
     SecurityImpl i = new SecurityImpl("IBM");
     mb = new BasketImpl(i);
     Assert.That(mb.hasStock);
     mb.Remove(i);
     Assert.That(!mb.hasStock);
     mb.Add(new SecurityImpl("LVS"));
     Assert.That(mb[0].Symbol=="LVS",mb[0].ToString());
     mb.Add(new SecurityImpl("IBM"));
     Assert.That(mb[1].Symbol=="IBM");
     BasketImpl newbasket = new BasketImpl(new SecurityImpl("FDX"));
     newbasket.Add(mb);
     mb.Clear();
     Assert.That(mb.Count==0);
     Assert.That(newbasket.Count==3);
 }