public void GetBikeAvailabilityDataTest()
 {
     try
     {
         var user = new UserReqBean();
         user.UserID = "334888";
         var citys = new List <CityReqBean>()
         {
             new CityReqBean()
             {
                 name = "Tai"
             },
             new CityReqBean()
             {
                 name  = "Keel",
                 Bikes = new List <BikeReqBean>()
                 {
                     new BikeReqBean()
                     {
                         name = "Ken"
                     },
                     new BikeReqBean()
                     {
                         name = "Ken",
                         Top  = 2
                     }
                 }
             },
         };
         user.Citys = citys;
         var templateService = CallWebService.Libray.Service.CallWebServiceFactory.Instance().TemplateService;
         var data            = templateService.GetBikeAvailabilityData(user);
         if (data.IsSuccess)
         {
             Console.WriteLine(JsonConvert.SerializeObject(data.Content, Formatting.Indented));
         }
         else
         {
             Console.WriteLine(data.ErrorMsg);
         }
         Assert.IsTrue(data.IsSuccess, data.ErrorMsg);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.StackTrace + "\n" + ex.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// (測試)取得動態指定[縣市]的公共自行車即時車位資料
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public ReturnModel <List <BikeAvailabilityRespBean> > GetBikeAvailabilityData(UserReqBean user)
        {
            var returnModel = new ReturnModel <List <BikeAvailabilityRespBean> >();

            try
            {
                var jsonStr1 = ObjectDeserializeJsonStr(user);                                                                                //無\r\n,有包含null欄位
                var jsonStr2 = ObjectDeserializeJsonStr(user, Newtonsoft.Json.Formatting.Indented);                                           //有\r\n,有包含null欄位
                var jsonStr3 = ObjectDeserializeJsonStr(user, Newtonsoft.Json.Formatting.None, Newtonsoft.Json.NullValueHandling.Ignore);     //無\r\n,無包含null欄位
                var jsonStr4 = ObjectDeserializeJsonStr(user, Newtonsoft.Json.Formatting.Indented, Newtonsoft.Json.NullValueHandling.Ignore); //有\r\n,無包含null欄位
                var url      = Properties.Settings.Default.TemplatePath + Properties.Settings.Default.TemplateApiAction + "?$top=10&$format=JSON";
                IDictionary <string, string> addHeaders = new Dictionary <string, string>()
                {
                    { "Key", "Value" }
                };
                returnModel = ExecuteService().Get <List <BikeAvailabilityRespBean> >(url, addHeaders);
            }
            catch (Exception ex)
            {
                returnModel.IsSuccess = false;
                returnModel.ErrorMsg  = GetExceptionDetailMessage(ex);
            }
            return(returnModel);
        }