示例#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);
        }
示例#2
0
 public async Task Delete(AppCredentialModel credential)
 {
     using (var client = new HttpClient())
     {
         Initialize(client);
         var response = await client.DeleteAsync(GetCredentialUrl(credential));
         response.TryException();
     }
 }
示例#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();
     }
 }
示例#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>();
     }
 }
示例#5
0
 protected string GetCredentialUrl(AppCredentialModel credential)
 {
     return $"{RoutePrefix}?{GetCredentialParams(credential)}";
 }
示例#6
0
 protected string GetCredentialParams(AppCredentialModel credential)
 {
     return $"{GetCredentialParams((CredentialModel) credential)}&appId={credential.AppId}";
 }