Example #1
0
        public static async Task <ApiResponse> GetNetTotals()
        {
            ApiResponse response = new ApiResponse();

            try
            {
                Network     network = new Network();
                NetTotals   totals  = new NetTotals();
                NetTotalsOM result  = await network.GetNetTotals();

                if (result != null)
                {
                    totals.TimeMillis     = result.TimeMillis;
                    totals.TotalBytesRecv = result.TotalBytesRecv;
                    totals.TotalBytesSent = result.TotalBytesSent;

                    response.Result = Newtonsoft.Json.Linq.JToken.FromObject(totals);
                }
                else
                {
                    response.Result = null;
                }
            }
            catch (ApiCustomException ex)
            {
                Logger.Singleton.Error(ex.Message);
                response.Error = new ApiError(ex.ErrorCode, ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error(ex.Message);
                response.Error = new ApiError(ex.HResult, ex.Message);
            }
            return(response);
        }
        public async Task GetNetTotals()
        {
            ApiResponse response = await NetworkApi.GetNetTotals();

            Assert.IsFalse(response.HasError);
            NetTotals result = response.GetResult <NetTotals>();

            Assert.IsNotNull(result);
        }