using KLHZ.Trader.Core.Exchange.Models.AssetsAccounting; namespace KLHZ.Trader.Core.Tests { public class TraderTests { [Test] public void IsBuyAllowedTest1() { var account = new ManagedAccount("111"); account.Total = 10000; account.Balance = 9000; account.Assets["123"] = new Asset() { AccountId = account.AccountId, Figi = "123", Ticker = "123", Type = AssetType.Futures, }; Assert.IsTrue(KLHZ.Trader.Core.Exchange.Services.Trader.IsBuyAllowed(account, 3000, 1, 0.5m, 0.3m)); } [Test] public void IsBuyAllowedTest2() { var account = new ManagedAccount("111"); account.Total = 10000; account.Balance = 5000; account.Assets["123"] = new Asset() { AccountId = account.AccountId, Figi = "123", Ticker = "123", Type = AssetType.Futures, }; Assert.IsFalse(KLHZ.Trader.Core.Exchange.Services.Trader.IsBuyAllowed(account, 3000, 1, 0.5m, 0.3m)); } [Test] public void IsBuyAllowedTest3() { var account = new ManagedAccount("111"); account.Total = 10000; account.Balance = 5000; account.Assets["123"] = new Asset() { AccountId = account.AccountId, Figi = "123", Ticker = "123", Type = AssetType.Futures, }; Assert.IsFalse(KLHZ.Trader.Core.Exchange.Services.Trader.IsBuyAllowed(account, 1500, 2, 0.5m, 0.3m)); } [Test] public void IsBuyAllowedTest4() { var account = new ManagedAccount("111"); account.Total = 10000; account.Balance = 3000; account.Assets["123"] = new Asset() { AccountId = account.AccountId, Figi = "123", Ticker = "123", Type = AssetType.Futures, }; Assert.IsFalse(KLHZ.Trader.Core.Exchange.Services.Trader.IsBuyAllowed(account, 1500, 1, 0.5m, 0.3m)); } [Test] public void IsBuyAllowedTest5() { var account = new ManagedAccount("111"); account.Total = 10000; account.Balance = 5000; account.Assets["123"] = new Asset() { AccountId = account.AccountId, Figi = "123", Ticker = "123", Type = AssetType.Common, }; Assert.IsTrue(KLHZ.Trader.Core.Exchange.Services.Trader.IsBuyAllowed(account, 3000, 1, 0.5m, 0.1m)); } } }