public InstrumTest() { DbContextOptionsBuilder <DaContext> builder = new DbContextOptionsBuilder <DaContext>(); builder.UseNpgsql("Username=postgres;Password=123;Host=localhost;Port=5432;Database=pulxer_test"); _options = builder.Options; _instrumDA = new InstrumDA(_options); }
public TickHistoryTest() { DbContextOptionsBuilder <DaContext> builder = new DbContextOptionsBuilder <DaContext>(); builder.UseNpgsql("Username=postgres;Password=123;Host=localhost;Port=5432;Database=pulxer_test"); _options = builder.Options; _tickHistoryDA = new TickHistoryDA(_options); _insDA = new InstrumDA(_options); _insID = _insDA.InsertInstrum("III", "", "", 1, 1, 1); }
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); }