internal async Task UpdateExecutionStatisticsIfEnabled() { if (_executionResult.ExecutionModel.GatherExecutionStatistics) { _sessionExecutionStatistics.MergeWith(await ConnectionAdapter.GetExecutionStatisticsAsync(_statementExecutionCancellationTokenSource.Token)); } }
public void SendingMessageViaEmail() { ConnectionAdapter adapter = new ConnectionAdapter(new Email()); bool success = adapter.SendMessage("Message3"); Assert.IsTrue(success); }
public RpcClientService(ConnectionAdapter connectionAdapter) : base(connectionAdapter) { _responses = new BlockingCollection <string>(); _correlationId = Guid.NewGuid().ToString(); _replyQueueName = _consumer.QueueName; }
public void SendingMessageViaPidgeon() { ConnectionAdapter adapter = new ConnectionAdapter(new Pidgeon()); bool success = adapter.SendMessage("Message2"); Assert.IsTrue(success); }
public override async Task <Statistics> TwentyFourHoursRollingStatsAsync(Product product) { string json = null; try { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.General, "Updating 24 hour stats Information."); Request request = new Request(ConnectionAdapter.Authentication.EndpointUrl, "GET", $"/products/{product.ID}/stats"); json = await ConnectionAdapter.RequestAsync(request); if (!string.IsNullOrEmpty(json)) { Statistics statistics = JsonSerializer.Deserialize <Statistics>(json); Statistics[product.ID] = statistics; return(statistics); } ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.JsonOutput, $"TwentyFourHoursRollingStatsAsync JSON:\r\n{json}"); } catch (Exception e) { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.Error, $"Method: TwentyFourHoursRollingStatsAsync\r\nException Stack Trace: {e.StackTrace}\r\nJSON: {json}"); } return(null); }
public DataTable GetSelect(string query = "") { Table = new DataTable(); using (ConnectionAdapter connection = getConnection(@ConnectionString)) { // Connect to the database then retrieve the schema information. connection.Open(); string command = ""; if (query != "") { command = query; } else { command = "SELECT * FROM " + TableName; } using (CommandAdapter cmd = getCommandAdapter(command, connection)) { using (IDataReader reader = cmd.ExecuteReader()) { Table.Load(reader); return(Table); } } } }
public void UpdateOrders_ShouldReturnAllOrders_WhenOrdersExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[ {{ ""id"": ""d0c5340b-6d6c-49d9-b567-48c4bfca13d2"", ""price"": ""0.10000000"", ""size"": ""0.01000000"", ""product_id"": ""BTC-USD"", ""side"": ""buy"", ""stp"": ""dc"", ""type"": ""limit"", ""time_in_force"": ""GTC"", ""post_only"": false, ""created_at"": ""2016-12-08T20:02:28.53864Z"", ""fill_fees"": ""0.0000000000000000"", ""filled_size"": ""0.00000000"", ""executed_value"": ""0.0000000000000000"", ""status"": ""open"", ""settled"": false }}, {{ ""id"": ""8b99b139-58f2-4ab2-8e7a-c11c846e3022"", ""price"": ""1.00000000"", ""size"": ""1.00000000"", ""product_id"": ""BTC-USD"", ""side"": ""buy"", ""stp"": ""dc"", ""type"": ""limit"", ""time_in_force"": ""GTC"", ""post_only"": false, ""created_at"": ""2016-12-08T20:01:19.038644Z"", ""fill_fees"": ""0.0000000000000000"", ""filled_size"": ""0.00000000"", ""executed_value"": ""0.0000000000000000"", ""status"": ""open"", ""settled"": false }} ]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Coinbase subjectUnderTest = new Coinbase(connectionFactory); //Act subjectUnderTest.UpdateOrdersAsync().Wait(); //Assert Assert.IsNotNull(subjectUnderTest.Orders); Assert.AreEqual(2, subjectUnderTest.Orders.Count); Assert.AreEqual("d0c5340b-6d6c-49d9-b567-48c4bfca13d2", subjectUnderTest.Orders[0].ID); Assert.AreEqual("8b99b139-58f2-4ab2-8e7a-c11c846e3022", subjectUnderTest.Orders[1].ID); }
public void UpdateProductHistoricCandles_ShouldReturnOrderBook_WhenAccountExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[ [1594131000000,""8244.44000000"",""8247.71000000"",""8234.56000000"",""8247.53000000"",""0.57541000"",1594131299999,""4743.74677830"",29,""0.51348500"",""4233.45949059"",""0""], [1594131300000,""8251.92000000"",""8263.73000000"",""8235.49000000"",""8261.31000000"",""0.73944300"",1594131599999,""6104.99268016"",73,""0.44151600"",""3646.66755442"",""0""], [1594131600000,""8258.99000000"",""8266.70000000"",""8253.56000000"",""8265.01000000"",""0.21730200"",1594131899999,""1795.04159624"",61,""0.12557200"",""1037.27246541"",""0""]]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Binance subjectUnderTest = new Binance(connectionFactory); Product product = new Product { ID = "BTCEUR" }; DateTime startingDateTime = new DateTime(2015, 4, 23).Date.ToUniversalTime(); DateTime endingDateTime = startingDateTime.AddMonths(6).ToUniversalTime(); //Act subjectUnderTest.UpdateProductHistoricCandlesAsync(product, startingDateTime, endingDateTime).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.HistoricRates); Assert.AreEqual(3, subjectUnderTest.HistoricRates.Count); Assert.AreEqual((decimal)8234.56000000, subjectUnderTest.HistoricRates[0].Low); Assert.AreEqual((decimal)0.57541000, subjectUnderTest.HistoricRates[0].Volume); }
public void SendingMessageViaTelephone() { ConnectionAdapter adapter = new ConnectionAdapter(new Telephone()); bool success = adapter.SendMessage("Message1"); Assert.IsTrue(success); }
public void UpdateAccountHolds_ShouldReturnAccountHolds_WhenAccountExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[ {{ ""id"": ""82dcd140-c3c7-4507-8de4-2c529cd1a28f"", ""account_id"": ""e0b3f39a-183d-453e-b754-0c13e5bab0b3"", ""created_at"": ""2014-11-06T10:34:47.123456Z"", ""updated_at"": ""2014-11-06T10:40:47.123456Z"", ""amount"": ""4.23"", ""type"": ""order"", ""ref"": ""0a205de4-dd35-4370-a285-fe8fc375a273"" }} ]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Coinbase subjectUnderTest = new Coinbase(connectionFactory); //Act subjectUnderTest.UpdateAccountHoldsAsync("82dcd140-c3c7-4507-8de4-2c529cd1a28f").Wait(); //Assert Assert.IsNotNull(subjectUnderTest.AccountHolds); Assert.AreEqual(1, subjectUnderTest.AccountHolds.Count); Assert.AreEqual("82dcd140-c3c7-4507-8de4-2c529cd1a28f", subjectUnderTest.AccountHolds[0].ID); Assert.AreEqual("e0b3f39a-183d-453e-b754-0c13e5bab0b3", subjectUnderTest.AccountHolds[0].AccountID); }
public ConnectionMonitorThread(ConnectionAdapter ca, NetworkTableConnection ntc) { base.\u002Ector(); ConnectionMonitorThread connectionMonitorThread = this; this.adapter = ca; this.connection = ntc; }
public void UpdateTickers_ShouldReturnProductsAndTickers_WhenProductsAndTickersExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"{{""symbol"":""BTCEUR"",""price"":""8287.76000000""}}") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Binance subjectUnderTest = new Binance(connectionFactory); List <Product> products = new List <Product> { new Product { ID = "BTCEUR" }, }; //Act subjectUnderTest.UpdateTickersAsync(products).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.Tickers); Assert.AreEqual(1, subjectUnderTest.Tickers.Count); Assert.AreEqual("BTCEUR", subjectUnderTest.Tickers[0].ProductID); Assert.AreEqual((decimal)8287.76000000, subjectUnderTest.Tickers[0].Price.ToDecimal()); Assert.IsNotNull(subjectUnderTest.CurrentPrices); Assert.AreEqual(subjectUnderTest.CurrentPrices[subjectUnderTest.Tickers[0].ProductID], subjectUnderTest.Tickers[0].Price.ToDecimal()); }
public void Test_Project_Connection_Fail_WrongParameter() { //Arrange , Act Logger log = new Logger("ConnectionTestWrongParameter.log"); ConnectionAdapter testConn = new ConnectionAdapter(@"http://localhost:8080/tfs/SzakdolgozatCollection", "Test_Project1", log); // Assert Assert.AreEqual(true, String.IsNullOrEmpty(testConn.TeamProject.Name)); // Throw the exception, because cant init the connection object. }
public void Test_Project_Connection_Right() { // Arrange , Act Logger log = new Logger("ConnectionTestRight.log"); ConnectionAdapter testConn = new ConnectionAdapter(@"http://localhost:8080/tfs/SzakdolgozatCollection", "Test_Project", log); // Assert Assert.AreEqual(false, String.IsNullOrEmpty(testConn.TeamProject.Name)); }
public void Initialize() { _httpMessageHandlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); _connectionAdapter = new ConnectionAdapter { Authentication = new Authentication("api_key", "passphrase", "NiWaGaqmhB3lgI/tQmm/gQ==", "https://api.binance.com", "wss://stream.binance.com:9443") }; }
public void Initialize() { _httpMessageHandlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); _connectionAdapter = new ConnectionAdapter { Authentication = new Authentication("api_key", "passphrase", "NiWaGaqmhB3lgI/tQmm/gQ==", "https://api.pro.coinbase.com", "wss://ws-feed.gdax.com") }; }
public void UpdateFills_ShouldReturnFills_WhenFillsExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[{{ ""trade_id"": 74, ""product_id"": ""BTC-EUR"", ""price"": ""10.00"", ""size"": ""0.01"", ""order_id"": ""d50ec984-77a8-460a-b958-66f114b0de9b"", ""created_at"": ""2014-11-07T22:19:28.578544Z"", ""liquidity"": ""T"", ""fee"": ""0.00025"", ""settled"": true, ""side"": ""buy"" }}, {{ ""trade_id"": 75, ""product_id"": ""BTC-EUR"", ""price"": ""10.00"", ""size"": ""0.01"", ""order_id"": ""990ec984-77a8-460a-b958-66f114b0de9c"", ""created_at"": ""2014-12-07T22:19:28.578544Z"", ""liquidity"": ""T"", ""fee"": ""0.00025"", ""settled"": true, ""side"": ""sell"" }}]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Coinbase subjectUnderTest = new Coinbase(connectionFactory); Product product = new Product { ID = "BTC-EUR", BaseCurrency = "BTC", QuoteCurrency = "EUR", BaseMinSize = "0.001", BaseMaxSize = "10000.00", QuoteIncrement = "0.01" }; //Act subjectUnderTest.UpdateFillsAsync(product).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.Fills); Assert.AreEqual(2, subjectUnderTest.Fills.Count); Assert.AreEqual(product.ID, subjectUnderTest.Fills[0].ProductID); }
static void Main(string[] args) { var connectionAdapter = new ConnectionAdapter(); var operatorService = new OperatorServices(connectionAdapter); Console.WriteLine(" [x] Awaiting RPC requests"); Console.WriteLine("Press [enter] to exit."); Console.ReadLine(); }
public override HccDbContext CreateHccDbContext() { var connString = WebAppSettings.HccEFConnectionString; var objectQualifier = Config.GetObjectQualifer(); var dataBaseOwner = Config.GetDataBaseOwner().TrimEnd('.'); var connAdapter = new TablePrefixModelAdapter(objectQualifier, new TableSchemaModelAdapter(dataBaseOwner)); var adapter = new ConnectionAdapter(connAdapter, Assembly.GetCallingAssembly()); return(new HccDbContext(adapter.AdaptConnection(connString), true)); }
/// <summary> /// Call this in a using block to share a connection over several calls. /// </summary> public virtual IConnectionAdapter CreateConnection() { if (_connectionAdapter != null) { //already have a connection, a wrapper to access it but won't be disposed return(new NestedConnection(_connectionAdapter)); } //top level connection _connectionAdapter = new ConnectionAdapter(Parameters); return(_connectionAdapter); }
public async Task <List <Ticker> > UpdateTickersAsync(List <Product> products) { string json = null; try { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.General, "Updating Update Tickers Information."); if (products == null || !products.Any()) { return(Tickers); } if (Tickers == null) { Tickers = new List <Ticker>(); } //Get price of all products foreach (Product product in products) { Request request = new Request(ConnectionAdapter.Authentication.EndpointUrl, "GET", $"/products/{product.ID}/ticker"); json = await ConnectionAdapter.RequestAsync(request); if (string.IsNullOrEmpty(json)) { return(Tickers); } Ticker ticker = JsonSerializer.Deserialize <Ticker>(json); Tickers?.RemoveAll(x => x.ProductID == product.ID); if (ticker == null) { continue; } ticker.ProductID = product.ID; Tickers.Add(ticker); } foreach (Ticker ticker in Tickers) { if (decimal.TryParse(ticker.Price, out decimal decimalPrice)) { CurrentPrices[ticker.ProductID] = decimalPrice; } } } catch (Exception e) { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.Error, $"Method: UpdateTickersAsync\r\nException Stack Trace: {e.StackTrace}\r\nJSON: {json}"); } return(Tickers); }
public void DeleteFromFile_Fail_FileDoesNotExist() { // Arrange Logger log = new Logger("Test_OperationManager1.log"); ConnectionAdapter conn = new ConnectionAdapter("http://localhost:8080/tfs/SzakdolgozatCollection", "Test_Project", log); ServerOperationManager serverOperation = new ServerOperationManager(conn, "Test_Project", "Test_Project", log); // Act bool result = serverOperation.DeleteFromFile("Something.csv"); // Assert Assert.AreEqual(false, result); }
public void UpdateBinanceFills_ShouldReturnFills_WhenFillsExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>(x => x.RequestUri.AbsoluteUri.Contains("/api/v1/time")), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"{{""serverTime"":1592395836992}}") })) .Verifiable(); _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>(x => x.RequestUri.AbsoluteUri.Contains("/api/v3/myTrades?")), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[{{ ""symbol"": ""BNBBTC"", ""id"": 28457, ""orderId"": 100234, ""orderListId"": -1, ""price"": ""4.00000100"", ""qty"": ""12.00000000"", ""quoteQty"": ""48.000012"", ""commission"": ""10.10000000"", ""commissionAsset"": ""BNB"", ""time"": 1499865549590, ""isBuyer"": true, ""isMaker"": false, ""isBestMatch"": true }}]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Binance subjectUnderTest = new Binance(connectionFactory); Product product = new Product { ID = "BNBBTC" }; //Act subjectUnderTest.UpdateBinanceFillsAsync(product).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.BinanceFill); Assert.AreEqual(1, subjectUnderTest.BinanceFill.Count); Assert.AreEqual(product.ID, subjectUnderTest.BinanceFill[0].ID); }
public void UpdateAccounts_ShouldReturnAccounts_WhenAccountExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[{{ ""id"": ""71452118-efc7-4cc4-8780-a5e22d4baa53"", ""currency"": ""BTC"", ""balance"": ""0.0000000000000000"", ""available"": ""0.0000000000000000"", ""hold"": ""0.0000000000000000"", ""profile_id"": ""75da88c5-05bf-4f54-bc85-5c775bd68254"", ""trading_enabled"":true }}, {{ ""id"": ""e316cb9a-0808-4fd7-8914-97829c1925de"", ""currency"": ""USD"", ""balance"": ""80.2301373066930000"", ""available"": ""79.2266348066930000"", ""hold"": ""1.0035025000000000"", ""profile_id"": ""75da88c5-05bf-4f54-bc85-5c775bd68254"" }}]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Coinbase subjectUnderTest = new Coinbase(connectionFactory); //Act subjectUnderTest.UpdateAccountsAsync().Wait(); //Assert Assert.IsNotNull(subjectUnderTest.Accounts); Assert.AreEqual(2, subjectUnderTest.Accounts.Count); Assert.AreEqual("71452118-efc7-4cc4-8780-a5e22d4baa53", subjectUnderTest.Accounts[0].ID); Assert.AreEqual("BTC", subjectUnderTest.Accounts[0].Currency); Assert.AreEqual((decimal)0.0000000000000000, subjectUnderTest.Accounts[0].Balance.ToDecimal()); Assert.AreEqual((decimal)0.0000000000000000, subjectUnderTest.Accounts[0].Available.ToDecimal()); Assert.AreEqual((decimal)0.0000000000000000, subjectUnderTest.Accounts[0].Hold.ToDecimal()); Assert.AreEqual("e316cb9a-0808-4fd7-8914-97829c1925de", subjectUnderTest.Accounts[1].ID); Assert.AreEqual("USD", subjectUnderTest.Accounts[1].Currency); Assert.AreEqual((decimal)80.2301373066930000, subjectUnderTest.Accounts[1].Balance.ToDecimal()); Assert.AreEqual((decimal)79.2266348066930000, subjectUnderTest.Accounts[1].Available.ToDecimal()); Assert.AreEqual((decimal)1.0035025000000000, subjectUnderTest.Accounts[1].Hold.ToDecimal()); }
public void Stop() { CheckWasDisposed(); try { IsActive = false; Listener.Close(); ConnectionAdapter.Close(); } catch { } StopInternal(); }
public void DeleteByIds_NoIds() { // Arrange Logger log = new Logger("Test_OperationManager3.log"); ConnectionAdapter conn = new ConnectionAdapter("http://localhost:8080/tfs/SzakdolgozatCollection", "Test_Project", log); ServerOperationManager serverOperation = new ServerOperationManager(conn, "Test_Project", "Test_Project", log); List <string> datas = new List <string>(); // Act bool result = serverOperation.DeleteByIds(datas); // Assert Assert.AreEqual(true, result); }
public async Task <Order> PostOrdersAsync(Order order) { string json = null; Order outputOrder = null; try { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.General, "Updating Post Order Information."); object data; if (order.Type == OrderType.Market.GetStringValue() || string.IsNullOrEmpty(order.Price)) { data = new { size = order.Size, side = order.Side, type = OrderType.Market.GetStringValue(), product_id = order.ProductID, stp = order.SelfTradePreventionType } } ; else { data = new { size = order.Size, price = order.Price, side = order.Side, type = OrderType.Limit.GetStringValue(), product_id = order.ProductID, stp = order.SelfTradePreventionType } }; Request request = new Request(ConnectionAdapter.Authentication.EndpointUrl, "POST", "/orders") { RequestBody = JsonSerializer.Serialize(data) }; json = await ConnectionAdapter.RequestAsync(request); outputOrder = JsonSerializer.Deserialize <Order>(json); } catch (Exception e) { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.Error, $"Method: PostOrdersAsync\r\nException Stack Trace: {e.StackTrace}\r\nJSON: {json}"); } return(outputOrder); }
public static DnnDbContext Instantiate() { var connBuilder = new EntityConnectionStringBuilder(); connBuilder.Provider = "System.Data.SqlClient"; connBuilder.ProviderConnectionString = WebAppSettings.HccConnectionString; connBuilder.Metadata = @"res://*/Data.DnnDbContext.csdl|res://*/Data.DnnDbContext.ssdl|res://*/Data.DnnDbContext.msl"; var objectQualifier = Config.GetObjectQualifer(); var dataBaseOwner = Config.GetDataBaseOwner().TrimEnd('.'); var connAdapter = new TablePrefixModelAdapter(objectQualifier, new TableSchemaModelAdapter(dataBaseOwner)); var adapter = new ConnectionAdapter(connAdapter, Assembly.GetCallingAssembly()); return(new DnnDbContext(adapter.AdaptConnection(connBuilder.ConnectionString), true)); }
public void DeleteFromFile_Fail_NoFileOnTheServer() { // Arrange Logger log = new Logger("Test_OperationManager2.log"); ConnectionAdapter conn = new ConnectionAdapter("http://*****:*****@"TestFiles\", fileName); bool result = serverOperation.DeleteFromFile(path); // Assert Assert.AreEqual(true, result); }
public void UpdateTickers_ShouldReturnProductsAndTickers_WhenProductsAndTickersExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"{{""price"": ""333.99"",""trade_id"": 4729088,""size"": ""0.193"",""bid"": ""333.98"",""ask"": ""333.99"",""volume"": ""5957.11914015"",""time"": ""2015-11-14T20:46:03.511254Z""}}") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Coinbase subjectUnderTest = new Coinbase(connectionFactory); List <Product> products = new List <Product> { new Product { ID = "BTC-EUR", BaseCurrency = "BTC", QuoteCurrency = "EUR", BaseMinSize = "0.001", BaseMaxSize = "10000.00", QuoteIncrement = "0.01" } }; //Act subjectUnderTest.UpdateTickersAsync(products).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.Tickers); Assert.AreEqual(1, subjectUnderTest.Tickers.Count); Assert.AreEqual("BTC-EUR", subjectUnderTest.Tickers[0].ProductID); Assert.AreEqual(4729088, subjectUnderTest.Tickers[0].TradeID); Assert.AreEqual((decimal)333.99, subjectUnderTest.Tickers[0].Price.ToDecimal()); Assert.AreEqual((decimal)0.193, subjectUnderTest.Tickers[0].Size.ToDecimal()); Assert.AreEqual((decimal)333.98, subjectUnderTest.Tickers[0].Bid.ToDecimal()); Assert.AreEqual((decimal)333.99, subjectUnderTest.Tickers[0].Ask.ToDecimal()); Assert.AreEqual((decimal)5957.11914015, subjectUnderTest.Tickers[0].Volume.ToDecimal()); Assert.AreEqual("2015-11-14T20:46:03.511254Z".ToDateTime(), subjectUnderTest.Tickers[0].Time.ToDateTime()); Assert.IsNotNull(subjectUnderTest.CurrentPrices); Assert.AreEqual(subjectUnderTest.CurrentPrices[subjectUnderTest.Tickers[0].ProductID], subjectUnderTest.Tickers[0].Price.ToDecimal()); }
public async Task <List <Account> > UpdateAccountsAsync(string accountId = "") { string json = null; try { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.General, "Updating Account Information."); Request request = new Request(ConnectionAdapter.Authentication.EndpointUrl, "GET", $"/accounts/{accountId}"); json = await ConnectionAdapter.RequestAsync(request); ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.JsonOutput, $"UpdateAccountsAsync JSON:\r\n{json}"); //check if we do not have any error messages Accounts = JsonSerializer.Deserialize <List <Account> >(json); if (Accounts != null) { Accounts.ForEach(account => { AccountInfo ??= new Dictionary <string, decimal>(); if (account.Balance.ToDecimal() <= 0) { return; } if (AccountInfo.ContainsKey(account.Currency)) { AccountInfo[account.Currency] = account.Balance.ToDecimal(); } else { AccountInfo.Add(account.Currency, account.Balance.ToDecimal()); } }); NotifyAccountInfo?.Invoke(ApplicationName, AccountInfo); Save(); } } catch (Exception e) { ProcessLogBroadcast?.Invoke(ApplicationName, MessageType.Error, $"Method: UpdateAccountsAsync\r\nException Stack Trace: {e.StackTrace}\r\nJSON: {json}"); } return(Accounts); }
public virtual void read(ConnectionAdapter ca) { IOException ioException; try { int num1 = (int) (sbyte) [email protected](); switch (num1) { case 0: ca.keepAlive(); return; case 1: int num2 = (int) [email protected](); ca.clientHello((char) num2); return; case 2: int num3 = (int) [email protected](); ca.protocolVersionUnsupported((char) num3); return; case 3: ca.serverHelloComplete(); return; case 16: string str1 = [email protected](); int num4 = (int) (sbyte) [email protected](); NetworkTableEntryType type = this.typeManager.getType((byte) num4); if (type == null) { string str2 = new StringBuilder().append("Unknown data type: 0x").append(Integer.toHexString(num4)).toString(); Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new BadMessageException(str2); } else { int num5 = (int) [email protected](); int num6 = (int) [email protected](); object obj = type.readValue(this.@is); ca.offerIncomingAssignment(new NetworkTableEntry((char) num5, str1, (char) num6, type, obj)); return; } case 17: int num7 = (int) [email protected](); int num8 = (int) [email protected](); NetworkTableEntry entry = ca.getEntry((char) num7); if (entry == null) { string str2 = new StringBuilder().append("Received update for unknown entry id: ").append(num7).toString(); Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new BadMessageException(str2); } else { object obj = entry.getType().readValue(this.@is); ca.offerIncomingUpdate(entry, (char) num8, obj); return; } default: string str3 = new StringBuilder().append("Unknown Network Table Message Type: ").append(num1).toString(); Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new BadMessageException(str3); } } catch (IOException ex) { int num = 1; ioException = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num); } throw Throwable.__\u003Cunmap\u003E((Exception) ioException); }