public IEnumerator Code() { const string url = RequestEndpoints.TextUrl; var request = new As <int>(new Get(new Code(new Text(url)))); return(HttxTestUtils.Await(request, response => { Assert.That(response, Is.EqualTo(200)); })); }
public IEnumerator TestLength() { const string url = RequestEndpoints.TextUrl; var length = (long)RequestEndpoints.TextResponse.Length; return(HttxTestUtils.Await(new Length(url), contentLength => { Assert.That(contentLength, Is.EqualTo(length)); })); }
public IEnumerator Complete() { const string text = RequestEndpoints.TextResponse; var request = new As <string>(new Complete <string>(text)); return(HttxTestUtils.Await(request, result => { Assert.That(result, Is.EqualTo(text)); })); }
public IEnumerator Json() { const string url = RequestEndpoints.JsonUrl; var request = new As <JsonResponseModel>(new Get(new Json(url))); return(HttxTestUtils.Await(request, result => { Assert.That(result.Text, Is.EqualTo("some-string")); Assert.That(result.Number, Is.EqualTo(7)); })); }
public IEnumerator Bearer() { const string url = RequestEndpoints.TextUrl; const string text = RequestEndpoints.TextResponse; var request = new As <string>(new Get(new Bearer(new Text(url), "token"))); return(HttxTestUtils.Await(request, response => { LogAssert.Expect(LogType.Log, new Regex("Bearer token")); Assert.That(response, Is.EqualTo(text)); })); }
public IEnumerator BasicAuth() { const string url = RequestEndpoints.TextUrl; const string text = RequestEndpoints.TextResponse; var request = new As <string>(new Get(new Basic(new Text(url), "login", "password"))); return(HttxTestUtils.Await(request, response => { LogAssert.Expect(LogType.Log, new Regex("Basic bG9naW46cGFzc3dvcmQ=")); Assert.That(response, Is.EqualTo(text)); })); }
public IEnumerator CancelContinue() { const string url = RequestEndpoints.TextUrl; const string text = RequestEndpoints.TextResponse; var tokenSource = new CancellationTokenSource(); var request = new As <string>(new Get(new Cancel(new Text(url), tokenSource.Token))); return(HttxTestUtils.Await(request, response => { Assert.That(response, Is.EqualTo(text)); })); }
public IEnumerator Bytes() { const string url = RequestEndpoints.TextUrl; const string text = RequestEndpoints.TextResponse; var responseBytes = System.Text.Encoding.UTF8.GetBytes(text); var request = new As <byte[]>(new Get(new Bytes(url))); return(HttxTestUtils.Await(request, bytes => { Assert.That(bytes, Is.EqualTo(responseBytes)); })); }
public IEnumerator Texture() { const string url = RequestEndpoints.TextureUrl; var request = new As <Texture2D>(new Get(new Texture(url))); return(HttxTestUtils.Await(request, texture => { Assert.That(texture, Is.Not.Null); Assert.That(texture.width, Is.EqualTo(RequestEndpoints.TextureSize)); Assert.That(texture.height, Is.EqualTo(RequestEndpoints.TextureSize)); Assert.That(texture.GetRawTextureData().Length, Is.EqualTo(RequestEndpoints.TextureBytes)); })); }
public IEnumerator TestHead() { const string url = RequestEndpoints.TextUrl; var length = RequestEndpoints.TextResponse.Length; return(HttxTestUtils.Await(new Head(url), headers => { var contentLengthHeader = headers.FirstOrDefault(h => h.Key == "Content-Length"); var contentLength = contentLengthHeader.Value; Assert.That(contentLengthHeader, Is.Not.Null); Assert.That(contentLength, Is.Not.Null); Assert.That(contentLength, Is.EqualTo($"{length}")); })); }
public IEnumerator Bundle() { const string url = RequestEndpoints.BundleUrl; var request = new As <AssetBundle>(new Get(new Bundle(url))); return(HttxTestUtils.Await(request, assetBundle => { Assert.That(assetBundle, Is.Not.Null); var assets = assetBundle.LoadAllAssets(); Assert.That(assets, Is.Not.Null); Assert.That(assets, Is.Not.Empty); Assert.That(assets.First().name, Is.EqualTo("text-file")); assetBundle.Unload(true); })); }
private static IEnumerator TestSuccessResponse(IAwaitable <string> awaitable) { return(HttxTestUtils.Await(awaitable, result => { Assert.That(result, Is.EqualTo(RequestEndpoints.TextResponse)); })); }