public void SetupTest() { // подготовить свежие котировки QuoteMaker.FillQuoteStorageWithDefaultValues(); conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); ACCOUNT eurAccount; AccountShareTestDataMaker.MakePammData(conn, out testAccount, out shareOwner, out eurAccount); }
public void SetupMethods() { EntityConnection connection; connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(out connection); exceptionConnectionPersistent = new TradeSharpConnectionPersistent(connection) { TestException = new Exception("DB context has failed") }; DatabaseContext.InitializeFake(connectionPersistent); }
public void InitTest() { // забить котировки QuoteMaker.FillQuoteStorageWithDefaultValues(); // словари TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock); // временно удалить файл начального наполнения (открытые ордера) TradeSharpConnectionPersistent.RestoreCsvFilesInMoqDbFolder(); //TradeSharpConnectionPersistent.RenameCsvFilesContainingAccountDataInMoqDbFolder(); conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); MakeTestData(); }
public void Setup() { conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); // подготовить свежие котировки QuoteMaker.FillQuoteStorageWithDefaultValues(); // словари TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock); ManagerTrade.MakeTestInstance(); testManager = ManagerAccount.Instance; // тестовые данные MakeTestData(); }
public void Setup() { conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); ManagerTrade.MakeTestInstance(); subscriber = (from usr in conn.PLATFORM_USER join w in conn.WALLET on usr.ID equals w.User join pa in conn.PLATFORM_USER_ACCOUNT on usr.ID equals pa.PlatformUser where pa.RightsMask == (int)AccountRights.Управление && w.Currency == SubscriberCurx && w.Balance > 40 select usr).First(); CreateServiceWithOwner("USD", 5, out serviceOwnerUsd, out serviceUsd); CreateServiceWithOwner("RUB", 25, out serviceOwnerRub, out serviceRub); QuoteStorage.Instance.UpdateValues("USDRUB", new QuoteData(35.20f, 35.20f, DateTime.Now)); // словари TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock); }
public void TearDown() { conn.Cleanup(); TradeSharpConnectionPersistent.RestoreCsvFilesInMoqDbFolder(); }
private void SetupDatabase() { connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); }
public void Setup() { connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); DatabaseContext.InitializeFake(connectionPersistent); }
public void InitTest() { connectionPersistent = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); }
public void SetupTest() { MakeFakeTradeProxy(); conn = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); // очистить подписки на портфели foreach (var sub in conn.USER_TOP_PORTFOLIO.ToList()) { conn.USER_TOP_PORTFOLIO.Remove(sub); } foreach (var portf in conn.TOP_PORTFOLIO.ToList()) { conn.TOP_PORTFOLIO.Remove(portf); } conn.SaveChanges(); // определить владельцев портфелей и подписантов portOwners = conn.PLATFORM_USER_ACCOUNT.Where(a => a.RightsMask == (int)AccountRights.Управление).Take(2).ToArray(); var lastOwnerId = portOwners[portOwners.Length - 1].PlatformUser; portSubs = conn.PLATFORM_USER_ACCOUNT.Where(a => a.RightsMask == (int)AccountRights.Управление).Where(a => a.PlatformUser > lastOwnerId).Take(2).ToArray(); // создать портфели portfolios = new [] { new TOP_PORTFOLIO { Criteria = "AYP", ParticipantCount = 3, OwnerUser = portOwners[0].PlatformUser, Name = "P1" }, new TOP_PORTFOLIO { Criteria = "DD", ParticipantCount = 2, OwnerUser = portOwners[1].PlatformUser, Name = "P1" } }; foreach (var pf in portfolios) { conn.TOP_PORTFOLIO.Add(pf); } conn.SaveChanges(); // подписать пользователей на портфели var curPortfolioIndex = 0; foreach (var usr in portSubs) { var port = portfolios[curPortfolioIndex++]; if (curPortfolioIndex == portfolios.Length) { curPortfolioIndex = 0; } conn.USER_TOP_PORTFOLIO.Add(new USER_TOP_PORTFOLIO { User = usr.PlatformUser, Portfolio = port.Id }); } conn.SaveChanges(); }
public void Setup() { // подыграть за торговый контракт SetupFakeServer(); // инициализировать словари (прежде всего - словарь тикеров) TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock); connection = TradeSharpConnectionPersistent.InitializeTradeSharpConnection(); // пользователь - владелец тестового сервиса var ownerUser = new PLATFORM_USER { Email = "*****@*****.**", Login = "******", Title = "Vafel", RoleMask = 0, Password = "******", RegistrationDate = DateTime.Now }; connection.PLATFORM_USER.Add(ownerUser); connection.SaveChanges(); // добавить категорию сигналов var srv = new SERVICE { FixedPrice = 0, Currency = "USD", User = ownerUser.ID }; connection.SERVICE.Add(srv); connection.SaveChanges(); serviceId = srv.ID; // добавить пользователя var user = new PLATFORM_USER { Email = "*****@*****.**", Login = "******", Password = "******", Title = "test", RegistrationDate = DateTime.Now }; connection.PLATFORM_USER.Add(user); connection.SaveChanges(); testUserId = user.ID; // добавить счет и сделок var group = connection.ACCOUNT_GROUP.First(g => !g.IsReal); var account = new ACCOUNT { AccountGroup = group.Code, Currency = AccountCurrency, Balance = 30000 }; connection.ACCOUNT.Add(account); connection.SaveChanges(); testAccountId = account.ID; // назначить пользователя владельцем счета connection.PLATFORM_USER_ACCOUNT.Add(new PLATFORM_USER_ACCOUNT { Account = testAccountId, PlatformUser = testUserId, RightsMask = (int)AccountRights.Управление }); // подписать счет на сигнал connection.SUBSCRIPTION.Add(new SUBSCRIPTION { User = testUserId, Service = serviceId, RenewAuto = true, TimeEnd = DateTime.Now.Date.AddDays(1) }); connection.SUBSCRIPTION_SIGNAL.Add(new SUBSCRIPTION_SIGNAL { User = testUserId, Service = serviceId, AutoTrade = true, PercentLeverage = 120, MinVolume = 10000, TargetAccount = testAccountId }); connection.SaveChanges(); // позиции MakeOrdersForTest(); foreach (var order in ordersForTest) { var pos = LinqToEntity.UndecorateOpenedPosition(order); connection.POSITION.Add(pos); } connection.SaveChanges(); // прописать срез котировок var nowTime = DateTime.Now; Contract.Util.BL.QuoteStorage.Instance.UpdateValues(new [] { "EURUSD", "GBPUSD", "USDJPY", "EURGBP" }, new [] { new QuoteData(1.3820f, 1.3822f, nowTime), new QuoteData(1.5350f, 1.5354f, nowTime), new QuoteData(90.81f, 90.83f, nowTime), new QuoteData(1.1107f, 1.1112f, nowTime) } ); }