add HTTP OMS server test for setting and retrieving globals
This commit is contained in:
parent
787c8923bd
commit
5fd65a161f
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
using System.Data.SqlTypes;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
@ -122,4 +123,47 @@ public class Tests
|
|||||||
Assert.That(json["result"].ToString(), Is.EqualTo("success"));
|
Assert.That(json["result"].ToString(), Is.EqualTo("success"));
|
||||||
Assert.That(json["value"]["widget"].ToString(), Is.EqualTo("root"));
|
Assert.That(json["value"]["widget"].ToString(), Is.EqualTo("root"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task Globals_Test_Get_Empty_Value()
|
||||||
|
{
|
||||||
|
Assert.That(program, Is.Not.Null);
|
||||||
|
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
HttpResponseMessage resp = client.Send(new HttpRequestMessage(HttpMethod.Get, BuildUrl(String.Format("/globals/{0}", KnownAttributeGuids.Text.ReferralURL))));
|
||||||
|
|
||||||
|
Assert.That(resp.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
|
||||||
|
Assert.That(resp.Content.Headers.ContentType.ToString(), Is.EqualTo("application/json"));
|
||||||
|
|
||||||
|
string content = await resp.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
JsonObject json = JsonNode.Parse(content) as JsonObject;
|
||||||
|
Assert.That(json["result"].ToString(), Is.EqualTo("success"));
|
||||||
|
Assert.That(json["value"], Is.Null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task Globals_Test_Set_Value()
|
||||||
|
{
|
||||||
|
Assert.That(program, Is.Not.Null);
|
||||||
|
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, BuildUrl(String.Format("/globals/{0}", KnownAttributeGuids.Text.ReferralURL)));
|
||||||
|
msg.Content = new System.Net.Http.FormUrlEncodedContent(new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("value", "test attribute value") });
|
||||||
|
HttpResponseMessage resp = client.Send(msg);
|
||||||
|
|
||||||
|
Assert.That(resp.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
|
||||||
|
Assert.That(resp.Content.Headers.ContentType.ToString(), Is.EqualTo("application/json"));
|
||||||
|
|
||||||
|
HttpResponseMessage resp2 = client.Send(new HttpRequestMessage(HttpMethod.Get, BuildUrl(String.Format("/globals/{0}", KnownAttributeGuids.Text.ReferralURL))));
|
||||||
|
|
||||||
|
Assert.That(resp2.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
|
||||||
|
Assert.That(resp2.Content.Headers.ContentType.ToString(), Is.EqualTo("application/json"));
|
||||||
|
|
||||||
|
string content = await resp2.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
JsonObject json = JsonNode.Parse(content) as JsonObject;
|
||||||
|
Assert.That(json["result"].ToString(), Is.EqualTo("success"));
|
||||||
|
Assert.That(json["value"].ToString(), Is.EqualTo("test attribute value"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user