Exemple #1
0
        public async Task DeleteManifestAsync_ValidatesArguments_Async()
        {
            var client = new ImageRegistryClient(new HttpClient());
            await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteManifestAsync(null, string.Empty, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteManifestAsync(string.Empty, null, default)).ConfigureAwait(false);
        }
Exemple #2
0
        public async Task Dispose_Works_Async()
        {
            var httpClient = new HttpClient();
            var client     = new ImageRegistryClient(httpClient);

            Assert.False(client.IsDisposed);

            client.Dispose();

            Assert.Throws <ObjectDisposedException>(() => httpClient.BaseAddress = new Uri("http://localhost:5000"));
            Assert.True(client.IsDisposed);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.DeleteBlobAsync(null, null, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.DeleteManifestAsync(null, null, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.GetBlobAsync(null, null, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.GetManifestAsync(null, null, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.ListTagsAsync(null, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.PushBlobAsync(null, null, null, default)).ConfigureAwait(false);

            await Assert.ThrowsAsync <ObjectDisposedException>(() => client.PushManifestAsync(null, null, null, default)).ConfigureAwait(false);
        }
Exemple #3
0
        public async Task DeleteManifestAsync_ThrowsOnError_Async()
        {
            var handler = new MockHttpMessageHandler();

            handler
            .When(HttpMethod.Delete, "http://localhost:5000/v2/registry/manifests/my-tag")
            .Respond(HttpStatusCode.NotFound);

            var httpClient = handler.ToHttpClient();

            httpClient.BaseAddress = new Uri("http://localhost:5000");

            var client = new ImageRegistryClient(httpClient);

            await Assert.ThrowsAsync <ImageRegistryException>(() => client.DeleteManifestAsync("registry", "my-tag", default)).ConfigureAwait(false);
        }
Exemple #4
0
        public async Task DeleteManifestAsync_Works_Async()
        {
            var handler = new MockHttpMessageHandler();

            handler
            .Expect(HttpMethod.Delete, "http://localhost:5000/v2/registry/manifests/my-tag")
            .Respond(HttpStatusCode.OK);

            var httpClient = handler.ToHttpClient();

            httpClient.BaseAddress = new Uri("http://localhost:5000");

            var client = new ImageRegistryClient(httpClient);

            // Should not throw
            await client.DeleteManifestAsync("registry", "my-tag", default).ConfigureAwait(false);

            handler.VerifyNoOutstandingExpectation();
        }