Пример #1
0
		public void LoadLocalization (string language = null)
		{
			if (language == null) {
				language = _localizer.GetCurrentCultureInfo ();
			}

			try {
				RestService restService = new RestService ("/Resources/Strings-" + language + ".json", ConfigurationManager.SERVER);

				Task<LocalizeModel> task = Task.Run (async () => await restService.GetDataFromJsonFile<LocalizeModel> ());
				task.Wait ();

				Data = task.Result;
			} catch {
				//var a = e.InnerExceptions[0].Data["message"];
				Data = new LocalizeModel ();
			}
		}
Пример #2
0
		public async void TestRestService()
		{ 
			RestService rest = new RestService ("/api/Vacations", _testServer);

			var vacationInfo = await rest.Get<VacationInfoModel> ("1");
			Assert.IsNotNull (vacationInfo, "Message: " + _testServer + "/api/vacations/get?id=1 return null");

			List<VacationInfoModel> vacationInfoList =await rest.Get<VacationInfoModel> ();
			Assert.IsNotNull (vacationInfoList, "Message: " + _testServer + "/api/vacations return null");

			var response = await rest.Post<VacationInfoModel> (new VacationInfoModel ());
			Assert.AreEqual (response.StatusCode, System.Net.HttpStatusCode.NoContent,"Message: " + _testServer + "/api/vacations/post return error");

			response = await rest.Post ("", "");
			Assert.AreEqual (response.StatusCode, System.Net.HttpStatusCode.NoContent,"Message: " + _testServer + "/api/vacations/post?name=*password=* return error");

			rest = new RestService("/Resources/Strings-"+_localizer.GetCurrentCultureInfo()+".json", _testServer);
			LocalizeModel localizeModel = await rest.GetDataFromJsonFile<LocalizeModel> ();
			Assert.IsNotNull (localizeModel, "Message: " + _testServer + "/api/vacations return null");
		}