コード例 #1
0
        public async Task FromStatusCode_NoContent_Works_Async()
        {
            var response  = new HttpResponseMessage(HttpStatusCode.NotFound);
            var exception = await ImageRegistryException.FromResponseAsync(response, default).ConfigureAwait(false);

            Assert.Equal("An unexpected error occurred when sending a request to the remote server.", exception.Message);
            Assert.Empty(exception.Errors);
            Assert.Equal(HttpStatusCode.NotFound, exception.StatusCode);
        }
コード例 #2
0
        public async Task FromStatusCode_JsonContent_Works_Async()
        {
            var response = new HttpResponseMessage(HttpStatusCode.BadRequest);

            response.Content = new StringContent("{\"errors\":[{\"code\":\"DIGEST_INVALID\",\"message\":\"provided digest did not match uploaded content\",\"detail\":\"digest parsing failed\"}]}", Encoding.UTF8, "application/json");

            var exception = await ImageRegistryException.FromResponseAsync(response, default).ConfigureAwait(false);

            Assert.Equal("provided digest did not match uploaded content", exception.Message);
            Assert.Single(exception.Errors);
            Assert.Equal(HttpStatusCode.BadRequest, exception.StatusCode);
        }
コード例 #3
0
        public async Task FromStatusCode_TextContent_Works_Async()
        {
            var response = new HttpResponseMessage(HttpStatusCode.NotFound);

            response.Content = new StringContent("NOT FOUND");

            var exception = await ImageRegistryException.FromResponseAsync(response, default).ConfigureAwait(false);

            Assert.Equal("NOT FOUND", exception.Message);
            Assert.Empty(exception.Errors);
            Assert.Equal(HttpStatusCode.NotFound, exception.StatusCode);
        }
コード例 #4
0
        public void WithMessage_Works()
        {
            var ex = new ImageRegistryException("this is a test");

            Assert.Equal("this is a test", ex.Message);
        }