Exemplo n.º 1
0
        public async Task CanSetRepositoryProperties()
        {
            // Arrange
            ContainerRepositoryClient client = CreateClient();
            RepositoryProperties      repositoryProperties = await client.GetPropertiesAsync();

            ContentProperties originalContentProperties = repositoryProperties.WriteableProperties;

            // Act
            await client.SetPropertiesAsync(
                new ContentProperties()
            {
                CanList   = false,
                CanRead   = false,
                CanWrite  = false,
                CanDelete = false,
            });

            // Assert
            RepositoryProperties properties = await client.GetPropertiesAsync();

            Assert.IsFalse(properties.WriteableProperties.CanList);
            Assert.IsFalse(properties.WriteableProperties.CanRead);
            Assert.IsFalse(properties.WriteableProperties.CanWrite);
            Assert.IsFalse(properties.WriteableProperties.CanDelete);

            // Cleanup
            await client.SetPropertiesAsync(originalContentProperties);
        }
Exemplo n.º 2
0
        public async Task CanGetRepositoryProperties()
        {
            RepositoryProperties properties = await _client.GetPropertiesAsync();

            Assert.AreEqual(_repositoryName, properties.Name);
            Assert.AreEqual(new Uri(TestEnvironment.Endpoint).Host, properties.Registry);
        }
        public async Task InitializeRepositoryProperties()
        {
            await _client.SetPropertiesAsync(
                new ContentProperties()
            {
                CanList   = true,
                CanRead   = true,
                CanWrite  = true,
                CanDelete = true
            });

            RepositoryProperties properties = await _client.GetPropertiesAsync();

            Assert.IsTrue(properties.WriteableProperties.CanList);
            Assert.IsTrue(properties.WriteableProperties.CanRead);
            Assert.IsTrue(properties.WriteableProperties.CanWrite);
            Assert.IsTrue(properties.WriteableProperties.CanDelete);
        }
Exemplo n.º 4
0
        public async Task CanGetRepositoryProperties()
        {
            // Arrange
            ContainerRepositoryClient client = CreateClient();

            // Act
            RepositoryProperties properties = await client.GetPropertiesAsync();

            // Assert
            Assert.AreEqual(_repositoryName, properties.Name);
        }
        public async Task CanGetRepositoryProperties()
        {
            // Arrange
            ContainerRepositoryClient client = CreateClient();

            // Act
            RepositoryProperties properties = await client.GetPropertiesAsync();

            // Assert
            Assert.AreEqual(_repositoryName, properties.Name);
            Assert.AreEqual(new Uri(TestEnvironment.Endpoint).Host, properties.Registry);
        }
Exemplo n.º 6
0
        public async Task HandleErrorsAsync()
        {
            Environment.SetEnvironmentVariable("REGISTRY_ENDPOINT", TestEnvironment.Endpoint);

            #region Snippet:ContainerRegistry_Tests_Samples_HandleErrorsAsync
            Uri endpoint = new Uri(Environment.GetEnvironmentVariable("REGISTRY_ENDPOINT"));

            // Create an invalid ContainerRepositoryClient
            string fakeRepositoryName        = "doesnotexist";
            ContainerRepositoryClient client = new ContainerRepositoryClient(endpoint, fakeRepositoryName, new DefaultAzureCredential());

            try
            {
                await client.GetPropertiesAsync();
            }
            catch (RequestFailedException ex) when(ex.Status == 404)
            {
                Console.WriteLine("Repository wasn't found.");
            }
            #endregion Snippet:ContainerRegistry_Tests_Samples_HandleErrorsAsync
        }