コード例 #1
0
        public IEnumerator CantResolveHost()
        {
            const string url     = RequestEndpoints.FakeUrl;
            var          request = new As <string>(new Get(new Text(url)));

            return(HttxTestUtils.AwaitException(request, e => {
                Assert.That(e, Is.Not.Null);
                Assert.That(e, Is.TypeOf <HttpException>());
            }));
        }
コード例 #2
0
        public IEnumerator NotFound()
        {
            const string url     = RequestEndpoints.NotFoundUrl;
            var          request = new As <string>(new Get(new Text(url)));

            return(HttxTestUtils.AwaitException(request, e => {
                Assert.That(e, Is.Not.Null);
                Assert.That(e, Is.TypeOf <HttpException>());

                var httpException = (HttpException)e;
                Assert.That(httpException.Code, Is.EqualTo(404));
            }));
        }
コード例 #3
0
ファイル: DecoratorsTests.cs プロジェクト: whitesharx/httx
        public IEnumerator CancelException()
        {
            const string url = RequestEndpoints.TextUrl;

            var tokenSource = new CancellationTokenSource();
            var request     = new As <string>(new Get(new Cancel(new Text(url), tokenSource.Token)));

            tokenSource.Cancel();

            return(HttxTestUtils.AwaitException(request, e => {
                Assert.That(e, Is.Not.Null);
                Assert.That(e, Is.TypeOf <OperationCanceledException>());
            }));
        }