public async Task PublicNightlyRepos() { const string acrName = "myacr.azurecr.io"; const string tenant = "mytenant"; const string username = "******"; const string password = "******"; const string subscription = "my sub"; const string resourceGroup = "group"; const string publicRepo1Name = "public/dotnet/core-nightly/repo1"; const string publicRepo2Name = "public/dotnet/core/repo2"; const string publicRepo3Name = "public/dotnet/core-nightly/repo3"; const string publicRepo4Name = "public/dotnet/nightly/repo4"; Catalog catalog = new Catalog { RepositoryNames = new List <string> { publicRepo1Name, publicRepo2Name, publicRepo3Name, publicRepo4Name } }; const string repo1Digest1 = "sha256:repo1digest1"; const string repo1Digest2 = "sha256:repo1digest2"; RepositoryManifests repo1Manifests = new RepositoryManifests { RepositoryName = publicRepo1Name, Manifests = new List <ManifestAttributes> { new ManifestAttributes { Digest = repo1Digest1, LastUpdateTime = DateTime.Now.Subtract(TimeSpan.FromDays(1)), Tags = new string[0] }, new ManifestAttributes { Digest = repo1Digest2, LastUpdateTime = DateTime.Now.Subtract(TimeSpan.FromDays(31)), Tags = new string[] { "tag" } } } }; const string repo3Digest1 = "sha256:repo3digest1"; const string repo3Digest2 = "sha256:repo3digest2"; RepositoryManifests repo3Manifests = new RepositoryManifests { RepositoryName = publicRepo3Name, Manifests = new List <ManifestAttributes> { new ManifestAttributes { Digest = repo3Digest1, LastUpdateTime = DateTime.Now.Subtract(TimeSpan.FromDays(29)), Tags = new string[0] }, new ManifestAttributes { Digest = repo3Digest2, LastUpdateTime = DateTime.Now.Subtract(TimeSpan.FromDays(31)), Tags = new string[0] } } }; const string repo4Digest1 = "sha256:repo4digest1"; RepositoryManifests repo4Manifests = new RepositoryManifests { RepositoryName = publicRepo4Name, Manifests = new List <ManifestAttributes> { new ManifestAttributes { Digest = repo4Digest1, LastUpdateTime = DateTime.Now.Subtract(TimeSpan.FromDays(60)), Tags = new string[0] } } }; Mock <IAcrClient> acrClientMock = new Mock <IAcrClient>(); acrClientMock .Setup(o => o.GetCatalogAsync()) .ReturnsAsync(catalog); foreach (string repoName in catalog.RepositoryNames) { acrClientMock .Setup(o => o.GetRepositoryAsync(repoName)) .ReturnsAsync(new Repository { Name = repoName }); } acrClientMock .Setup(o => o.GetRepositoryManifestsAsync(publicRepo1Name)) .ReturnsAsync(repo1Manifests); acrClientMock .Setup(o => o.GetRepositoryManifestsAsync(publicRepo3Name)) .ReturnsAsync(repo3Manifests); acrClientMock .Setup(o => o.GetRepositoryManifestsAsync(publicRepo4Name)) .ReturnsAsync(repo4Manifests); acrClientMock .Setup(o => o.DeleteRepositoryAsync(publicRepo4Name)) .ReturnsAsync(new DeleteRepositoryResponse()); Mock <IAcrClientFactory> acrClientFactoryMock = new Mock <IAcrClientFactory>(); acrClientFactoryMock .Setup(o => o.CreateAsync(acrName, tenant, username, password)) .ReturnsAsync(acrClientMock.Object); CleanAcrImagesCommand command = new CleanAcrImagesCommand( acrClientFactoryMock.Object, Mock.Of <ILoggerService>()); command.Options.Subscription = subscription; command.Options.Password = password; command.Options.Username = username; command.Options.Tenant = tenant; command.Options.ResourceGroup = resourceGroup; command.Options.RegistryName = acrName; command.Options.RepoName = "public/dotnet/*nightly/*"; command.Options.Action = CleanAcrImagesAction.PruneDangling; command.Options.Age = 30; await command.ExecuteAsync(); acrClientMock.Verify(o => o.DeleteManifestAsync(publicRepo1Name, repo1Digest1), Times.Never); acrClientMock.Verify(o => o.DeleteManifestAsync(publicRepo1Name, repo1Digest2), Times.Never); acrClientMock.Verify(o => o.DeleteManifestAsync(publicRepo2Name, It.IsAny <string>()), Times.Never); acrClientMock.Verify(o => o.DeleteManifestAsync(publicRepo3Name, repo3Digest1), Times.Never); acrClientMock.Verify(o => o.DeleteManifestAsync(publicRepo3Name, repo3Digest2)); acrClientMock.Verify(o => o.DeleteRepositoryAsync(publicRepo4Name)); }