Esempio n. 1
0
        public async Task GetVMSizesAndPricesAsync_UsesCache()
        {
            var azureProxy        = GetMockAzureProxy();
            var cachingAzureProxy = new CachingAzureProxy(azureProxy.Object, cache, new Mock <ILogger <CachingAzureProxy> >().Object);

            var vmSizesAndPrices1 = await cachingAzureProxy.GetVmSizesAndPricesAsync();

            var vmSizesAndPrices2 = await cachingAzureProxy.GetVmSizesAndPricesAsync();

            azureProxy.Verify(mock => mock.GetVmSizesAndPricesAsync(), Times.Once());
            Assert.AreEqual(vmSizesAndPrices1, vmSizesAndPrices2);
            Assert.AreEqual(4, vmSizesAndPrices1.Count);
        }
Esempio n. 2
0
        public async Task GetStorageAccountInfoAsync_UsesCache()
        {
            var azureProxy         = GetMockAzureProxy();
            var storageAccountInfo = new StorageAccountInfo {
                Name = "defaultstorageaccount", Id = "Id", BlobEndpoint = "https://defaultstorageaccount/", SubscriptionId = "SubId"
            };

            azureProxy.Setup(a => a.GetStorageAccountInfoAsync(It.IsAny <string>())).Returns(Task.FromResult(storageAccountInfo));
            var cachingAzureProxy = new CachingAzureProxy(azureProxy.Object, cache, new Mock <ILogger <CachingAzureProxy> >().Object);

            var info1 = await cachingAzureProxy.GetStorageAccountInfoAsync("defaultstorageaccount");

            var info2 = await cachingAzureProxy.GetStorageAccountInfoAsync("defaultstorageaccount");

            azureProxy.Verify(mock => mock.GetStorageAccountInfoAsync("defaultstorageaccount"), Times.Once());
            Assert.AreEqual(storageAccountInfo, info1);
            Assert.AreEqual(info1, info2);
        }
Esempio n. 3
0
        public async Task GetBatchAccountQuotasAsync_UsesCache()
        {
            var azureProxy  = GetMockAzureProxy();
            var batchQuotas = new AzureBatchAccountQuotas {
                ActiveJobAndJobScheduleQuota = 1, PoolQuota = 1, DedicatedCoreQuota = 5, LowPriorityCoreQuota = 10
            };

            azureProxy.Setup(a => a.GetBatchAccountQuotasAsync()).Returns(Task.FromResult(batchQuotas));
            var cachingAzureProxy = new CachingAzureProxy(azureProxy.Object, cache, new Mock <ILogger <CachingAzureProxy> >().Object);

            var quotas1 = await cachingAzureProxy.GetBatchAccountQuotasAsync();

            var quotas2 = await cachingAzureProxy.GetBatchAccountQuotasAsync();

            azureProxy.Verify(mock => mock.GetBatchAccountQuotasAsync(), Times.Once());
            Assert.AreEqual(batchQuotas, quotas1);
            Assert.AreEqual(quotas1, quotas2);
        }
Esempio n. 4
0
        public async Task GetContainerRegistryInfoAsync_UsesCache()
        {
            var azureProxy            = GetMockAzureProxy();
            var containerRegistryInfo = new ContainerRegistryInfo {
                RegistryServer = "registryServer1", Username = "******", Password = "******"
            };

            azureProxy.Setup(a => a.GetContainerRegistryInfoAsync(It.IsAny <string>())).Returns(Task.FromResult(containerRegistryInfo));
            var cachingAzureProxy = new CachingAzureProxy(azureProxy.Object, cache, new Mock <ILogger <CachingAzureProxy> >().Object);

            var info1 = await cachingAzureProxy.GetContainerRegistryInfoAsync("registryServer1/imageName1:tag1");

            var info2 = await cachingAzureProxy.GetContainerRegistryInfoAsync("registryServer1/imageName1:tag1");

            azureProxy.Verify(mock => mock.GetContainerRegistryInfoAsync("registryServer1/imageName1:tag1"), Times.Once());
            Assert.AreEqual(containerRegistryInfo, info1);
            Assert.AreEqual(info1, info2);
        }