public void InsertGetInstrums_() { int id1 = _instrumDA.InsertInstrum("TICKER1", "“икер1", "“икер 1", 10, 2, 0.1m); int id2 = _instrumDA.InsertInstrum("TICKER2", "“икер2", "“икер 2", 1, 3, 1); var list = _instrumDA.GetInstrumList(); var instrums = _instrumDA.GetInstrums(); var item = list.FirstOrDefault(r => r.InsID == id1); var ins = instrums.FirstOrDefault(r => r.InsID == id1); Assert.Equal(id1, item.InsID); Assert.Equal("TICKER1", item.Ticker); Assert.Equal("“икер1", item.ShortName); Assert.Equal(id1, ins.InsID); Assert.Equal("TICKER1", ins.Ticker); Assert.Equal("“икер1", ins.ShortName); Assert.Equal("“икер 1", ins.Name); Assert.Equal(2, ins.Decimals); Assert.Equal(10, ins.LotSize); Assert.Equal(0.1m, ins.PriceStep); var ins1 = _instrumDA.GetInstrum(id1); var ins2 = _instrumDA.GetInstrum(0, "TICKER2"); Assert.Equal(id1, ins1.InsID); Assert.Equal("TICKER1", ins1.Ticker); Assert.Equal("“икер1", ins1.ShortName); Assert.Equal("“икер 1", ins1.Name); Assert.Equal(2, ins1.Decimals); Assert.Equal(10, ins1.LotSize); Assert.Equal(0.1m, ins1.PriceStep); Assert.Equal(id2, ins2.InsID); Assert.Equal("TICKER2", ins2.Ticker); Assert.Equal("“икер2", ins2.ShortName); Assert.Equal("“икер 2", ins2.Name); Assert.Equal(3, ins2.Decimals); Assert.Equal(1, ins2.LotSize); Assert.Equal(1, ins2.PriceStep); _instrumDA.DeleteInstrumByID(id1); _instrumDA.DeleteInstrumByID(id2); }
public void DeleteAccountData_() { int accID; // create var accDA = new AccountDA(_options); var insDA = new InstrumDA(_options); var posDA = new PositionDA(_options); int insID = insDA.InsertInstrum("", "", "", 1, 0, 1); accID = accDA.CreateAccount("code", "name", 100, true, AccountTypes.Test).AccountID; accDA.CreateCash(accID, 0, 0, 0, 0, 0, 0); var order = accDA.CreateOrder(accID, DateTime.Now, insID, Platform.BuySell.Buy, 1, null, Platform.OrderStatus.Active, null, 0); var trade = accDA.CreateTrade(accID, order.OrderID, DateTime.Now, insID, Platform.BuySell.Buy, 1, 0, 0, 0); var so = accDA.CreateStopOrder(accID, DateTime.Now, insID, Platform.BuySell.Buy, Platform.StopOrderType.StopLoss, null, 0, null, 0, Platform.StopOrderStatus.Active, null, 0); var h = accDA.CreateHolding(accID, insID, 1); var pos = posDA.CreatePosition(accID, insID, PosTypes.Long, DateTime.Now, 0, 0, null, null); posDA.AddPosTrade(pos.PosID, trade.TradeID); accDA.DeleteAccountData(accID); Assert.Null(accDA.GetCash(accID)); // данные удалились Assert.Empty(accDA.GetOrders(accID)); Assert.Empty(accDA.GetStopOrders(accID)); Assert.Empty(accDA.GetTrades(accID)); Assert.Empty(accDA.GetHoldings(accID)); Assert.Empty(posDA.GetPosTrades(new List <int>() { pos.PosID })); Assert.Empty(posDA.GetPositions(accID, false)); Assert.NotNull(accDA.GetAccountByID(accID)); // а сам account остался // cleanup insDA.DeleteInstrumByID(insID); accDA.DeleteAccount(accID); }