예제 #1
0
        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));
            }));
        }
예제 #2
0
        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));
            }));
        }
예제 #3
0
        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));
            }));
        }
예제 #4
0
        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));
            }));
        }
예제 #5
0
        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));
            }));
        }
예제 #6
0
        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));
            }));
        }
예제 #7
0
        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));
            }));
        }
예제 #8
0
        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));
            }));
        }
예제 #9
0
        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));
            }));
        }
예제 #10
0
        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}"));
            }));
        }
예제 #11
0
        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);
            }));
        }
예제 #12
0
 private static IEnumerator TestSuccessResponse(IAwaitable <string> awaitable)
 {
     return(HttxTestUtils.Await(awaitable, result => {
         Assert.That(result, Is.EqualTo(RequestEndpoints.TextResponse));
     }));
 }