Ejemplo n.º 1
0
        private Task <StorageAccountGetResponse> CreateGetResponse(string serviceName)
        {
            Task <StorageAccountGetResponse> resultTask;
            var data = accounts.FirstOrDefault(a => a.Name == serviceName);

            if (data != null)
            {
                var storageServiceGetResponse = new StorageAccountGetResponse
                {
                    StorageAccount = new StorageAccount
                    {
                        Name       = data.Name,
                        Properties = new StorageAccountProperties
                        {
                            Endpoints =
                            {
                                new Uri(data.BlobEndpoint),
                                new Uri(data.QueueEndpoint),
                                new Uri(data.TableEndpoint)
                            }
                        }
                    }
                };
                resultTask = Tasks.FromResult(storageServiceGetResponse);
            }
            else
            {
                resultTask = Tasks.FromException <StorageAccountGetResponse>(ClientMocks.Make404Exception());
            }
            return(resultTask);
        }
Ejemplo n.º 2
0
        private Task <StorageAccountGetKeysResponse> CreateGetKeysResponse(string serviceName)
        {
            Task <StorageAccountGetKeysResponse> resultTask;
            var data = accounts.FirstOrDefault(a => a.Name == serviceName);

            if (data != null)
            {
                var response = new StorageAccountGetKeysResponse
                {
                    PrimaryKey   = data.PrimaryKey,
                    SecondaryKey = data.SecondaryKey,
                    StatusCode   = HttpStatusCode.OK
                };
                resultTask = Tasks.FromResult(response);
            }
            else
            {
                resultTask = Tasks.FromException <StorageAccountGetKeysResponse>(ClientMocks.Make404Exception());
            }
            return(resultTask);
        }
        private void SetMocks(List<WindowsAzure.Subscriptions.Models.SubscriptionListOperationResponse.Subscription> rdfeSubscriptions,
            List<Azure.Subscriptions.Models.Subscription> csmSubscriptions)
        {
            ClientMocks clientMocks = new ClientMocks(new Guid(defaultSubscription));

            clientMocks.LoadRdfeSubscriptions(rdfeSubscriptions);
            clientMocks.LoadCsmSubscriptions(csmSubscriptions);

            AzureSession.ClientFactory = new MockClientFactory(new object[] { clientMocks.RdfeSubscriptionClientMock.Object,
                clientMocks.CsmSubscriptionClientMock.Object });

            AzureSession.AuthenticationFactory = new MockAuthenticationFactory();
        }
Ejemplo n.º 4
0
        private void SetMocks(List<RDFESubscription> rdfeSubscriptions,
            List<CSMSubscription> csmSubscriptions,
            List<TenantIdDescription> tenants = null,
            Func<AzureAccount, AzureEnvironment, string, IAccessToken> tokenProvider = null)
        {
            ClientMocks clientMocks = new ClientMocks(new Guid(defaultSubscription));

            clientMocks.LoadRdfeSubscriptions(rdfeSubscriptions);
            clientMocks.LoadCsmSubscriptions(csmSubscriptions);
            clientMocks.LoadTenants(tenants);

            AzureSession.ClientFactory = new MockClientFactory(new object[] { clientMocks.RdfeSubscriptionClientMock.Object,
                clientMocks.CsmSubscriptionClientMock.Object })
            {
                MoqClients = true
            };

            var mockFactory = new MockTokenAuthenticationFactory();
            if (tokenProvider != null)
            {
                mockFactory.TokenProvider = tokenProvider;
            }

            AzureSession.AuthenticationFactory = mockFactory;
        }