Esempio n. 1
0
        public void Test()
        {

            var proxy = new AppProxy(BaseAddress);

            var credential = new AppCredentialModel
            {
                AppId = AppId,
                Key = AdminKey
            };

            var app = proxy.Get(credential).Result;
            Assert.AreEqual(AppName, app.Name);
            Assert.AreEqual(AppSettings, app.Settings);

            proxy.Update(credential, new ApplicationModel
            {
                Name = "newApp",
                Settings = "newSettings"
            }).Wait();

            app = proxy.Get(credential).Result;
            Assert.AreEqual("newApp", app.Name);
            Assert.AreEqual("newSettings", app.Settings);
        }
Esempio n. 2
0
 public async Task Delete(AppCredentialModel credential)
 {
     using (var client = new HttpClient())
     {
         Initialize(client);
         var response = await client.DeleteAsync(GetCredentialUrl(credential));
         response.TryException();
     }
 }
Esempio n. 3
0
 public async Task Update(AppCredentialModel credential, ApplicationModel data)
 {
     using (var client = new HttpClient())
     {
         Initialize(client);
         var response = await client.PostAsync(GetCredentialUrl(credential), data, JsonFormatter);
         response.TryException();
     }
 }
Esempio n. 4
0
 public async Task<ApplicationModel> Get(AppCredentialModel credential)
 {
     using (var client = new HttpClient())
     {
         Initialize(client);
         var response = await client.GetAsync(GetCredentialUrl(credential));
         response.TryException();
         return await response.Content.ReadAsAsync<ApplicationModel>();
     }
 }
Esempio n. 5
0
 protected string GetCredentialUrl(AppCredentialModel credential)
 {
     return $"{RoutePrefix}?{GetCredentialParams(credential)}";
 }
Esempio n. 6
0
 protected string GetCredentialParams(AppCredentialModel credential)
 {
     return $"{GetCredentialParams((CredentialModel) credential)}&appId={credential.AppId}";
 }