public void TestStorageAccountPermission() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.storageAccountsFixture.AddClfsStorageAccount( context, "perm", waitForStorageTarget: false, addPermissions: false, testOutputHelper: this.testOutputHelper, waitForPermissions: false, maxRequestTries: 0)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); this.testOutputHelper.WriteLine($"{ex.Body.Error.Code}"); this.testOutputHelper.WriteLine($"{ex.Body.Error.Target}"); Assert.Contains("InvalidParameter", ex.Body.Error.Code); Assert.Equal("storageTarget.clfs.target", ex.Body.Error.Target); Assert.Contains("hasn't sufficient permissions", ex.Body.Error.Message); } }
public void TestClfsTargetInvalidResourceGroup() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; var storageAccount = this.storageAccountsFixture.AddStorageAccount(context, this.fixture.ResourceGroup, testOutputHelper: this.testOutputHelper); var blobContainer = this.storageAccountsFixture.AddBlobContainer(context, this.fixture.ResourceGroup, storageAccount); StorageTarget storageTargetParameters = this.fixture.CacheHelper.CreateClfsStorageTargetParameters( storageAccount.Name, blobContainer.Name, "/junction", resourceGroupName: "invalidrs"); CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.fixture.CacheHelper.CreateStorageTarget( this.fixture.Cache.Name, "invalidst", storageTargetParameters, this.testOutputHelper, maxRequestTries: 0)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); this.testOutputHelper.WriteLine($"{ex.Body.Error.Code}"); this.testOutputHelper.WriteLine($"{ex.Body.Error.Target}"); Assert.Contains("InvalidParameter", ex.Body.Error.Code); Assert.Equal("storageTarget.clfs.target", ex.Body.Error.Target); } }
public void TestStorageTargetInvalidTargetType() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; StorageTarget storageTargetParameters = this.fixture.CacheHelper.CreateClfsStorageTargetParameters( "storageAccount", "blobContainer", "junction"); storageTargetParameters.TargetType = "invalid"; CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.fixture.CacheHelper.CreateStorageTarget( this.fixture.Cache.Name, "invalidst", storageTargetParameters, this.testOutputHelper, maxRequestTries: 0)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); this.testOutputHelper.WriteLine($"{ex.Body.Error.Code}"); this.testOutputHelper.WriteLine($"{ex.Body.Error.Target}"); Assert.Contains("InvalidParameter", ex.Body.Error.Code); Assert.Equal("storageTarget.targetType", ex.Body.Error.Target); } }
public void TestInvalidSku() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = Constants.DefaultAPIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.fixture.CacheHelper.Create("InvalidCacheSku", "InvalidSku", 3072)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); Assert.Equal("InvalidParameter", ex.Body.Error.Code); Assert.Equal("sku", ex.Body.Error.Target); } }
public void TestDeleteClfsStorageTarget() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; var storageTarget = this.storageAccountsFixture.AddClfsStorageAccount(context, suffix: "del", waitForPermissions: false, testOutputHelper: this.testOutputHelper); TestUtilities.Wait(new TimeSpan(0, 0, 60)); this.fixture.CacheHelper.DeleteStorageTarget(this.fixture.Cache.Name, storageTarget.Name, this.testOutputHelper); TestUtilities.Wait(new TimeSpan(0, 0, 60)); CloudErrorException ex = Assert.Throws <CloudErrorException>(() => this.fixture.CacheHelper.GetStorageTarget(this.fixture.Cache.Name, storageTarget.Name, true)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); Assert.Contains("NotFound", ex.Body.Error.Code); } }
public void TestInvalidSubscription() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = Constants.DefaultAPIVersion; client.SubscriptionId = "4525f627-2e14-411c-96b9-7df2be6eeb93"; this.fixture.CacheHelper.StoragecacheManagementClient = client; CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.fixture.CacheHelper.Create("InvalidSubscriptionId", this.fixture.Cache.Sku.Name, 3072, true)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); Assert.Equal("SubscriptionNotFound", ex.Body.Error.Code); client.SubscriptionId = this.fixture.SubscriptionID; this.fixture.CacheHelper.StoragecacheManagementClient = client; } }
public void TestInvalidSku() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; var cacheIdentity = new CacheIdentity() { Type = CacheIdentityType.SystemAssigned }; CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.fixture.CacheHelper.Create("InvalidCacheSku", "InvalidSku", 3072, identity: cacheIdentity)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); Assert.Equal("InvalidParameter", ex.Body.Error.Code); Assert.Equal("sku", ex.Body.Error.Target); } }
public void TestInvalidSubscription() { this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; client.SubscriptionId = "4525f627-2e14-411c-96b9-7df2be6eeb93"; this.fixture.CacheHelper.StoragecacheManagementClient = client; var cacheIdentity = new CacheIdentity() { Type = CacheIdentityType.SystemAssigned }; CloudErrorException ex = Assert.Throws <CloudErrorException>( () => this.fixture.CacheHelper.Create("InvalidSubscriptionId", this.fixture.Cache.Sku.Name, 3072, identity: cacheIdentity, skipGet: true)); this.testOutputHelper.WriteLine($"{ex.Body.Error.Message}"); Assert.Equal("SubscriptionNotFound", ex.Body.Error.Code); client.SubscriptionId = this.fixture.SubscriptionID; this.fixture.CacheHelper.StoragecacheManagementClient = client; } }
/// <summary> /// Get the list of Cache Usage Models available to this subscription. /// </summary> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="CloudErrorException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <HttpOperationResponse <UsageModelsResult> > ListWithHttpMessagesAsync(Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List <string> _queryParameters = new List <string>(); if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { _url += "?" + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200) { var ex = new CloudErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <CloudError>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new HttpOperationResponse <UsageModelsResult>(); _result.Request = _httpRequest; _result.Response = _httpResponse; // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <UsageModelsResult>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
/// <summary> /// Create or update a Storage Target. This operation is allowed at any time, /// but if the Cache is down or unhealthy, the actual creation/modification of /// the Storage Target may be delayed until the Cache is healthy again. /// </summary> /// <param name='resourceGroupName'> /// Target resource group. /// </param> /// <param name='cacheName'> /// Name of Cache. Length of name must be not greater than 80 and chars must be /// in list of [-0-9a-zA-Z_] char class. /// </param> /// <param name='storageTargetName'> /// Name of the Storage Target. Length of name must be not greater than 80 and /// chars must be in list of [-0-9a-zA-Z_] char class. /// </param> /// <param name='storagetarget'> /// Object containing the definition of a Storage Target. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="CloudErrorException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <HttpOperationResponse <StorageTarget> > CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string cacheName, string storageTargetName, StorageTarget storagetarget = default(StorageTarget), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } if (cacheName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "cacheName"); } if (cacheName != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(cacheName, "^[-0-9a-zA-Z_]{1,80}$")) { throw new ValidationException(ValidationRules.Pattern, "cacheName", "^[-0-9a-zA-Z_]{1,80}$"); } } if (storageTargetName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "storageTargetName"); } if (storageTargetName != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(storageTargetName, "^[-0-9a-zA-Z_]{1,80}$")) { throw new ValidationException(ValidationRules.Pattern, "storageTargetName", "^[-0-9a-zA-Z_]{1,80}$"); } } if (storagetarget != null) { storagetarget.Validate(); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("cacheName", cacheName); tracingParameters.Add("storageTargetName", storageTargetName); tracingParameters.Add("storagetarget", storagetarget); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}").ToString(); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{cacheName}", System.Uri.EscapeDataString(cacheName)); _url = _url.Replace("{storageTargetName}", System.Uri.EscapeDataString(storageTargetName)); List <string> _queryParameters = new List <string>(); if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { _url += "?" + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (storagetarget != null) { _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(storagetarget, Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { var ex = new CloudErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <CloudError>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new HttpOperationResponse <StorageTarget>(); _result.Request = _httpRequest; _result.Response = _httpResponse; // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <StorageTarget>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } // Deserialize Response if ((int)_statusCode == 201) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <StorageTarget>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
public void TestCreateClfsStorageTarget() { testOutputHelper.WriteLine(storageAccountsFixture.notes.ToString()); this.testOutputHelper.WriteLine($"Running in {HttpMockServer.GetCurrentMode()} mode."); using (StorageCacheTestContext context = new StorageCacheTestContext(this)) { var client = context.GetClient <StorageCacheManagementClient>(); client.ApiVersion = StorageCacheTestEnvironmentUtilities.APIVersion; this.fixture.CacheHelper.StoragecacheManagementClient = client; StorageTarget storageTarget; var suffix = "cre"; storageTarget = this.storageAccountsFixture.AddClfsStorageAccount(context, suffix: suffix, waitForPermissions: false, testOutputHelper: this.testOutputHelper); string id = $"/subscriptions/{this.fixture.SubscriptionID}" + $"/resourceGroups/{this.fixture.ResourceGroup.Name}" + $"/providers/Microsoft.StorageCache/caches/{this.fixture.Cache.Name}" + $"/storageTargets/{this.fixture.ResourceGroup.Name + suffix}"; string clfsTarget = $"/subscriptions/{this.fixture.SubscriptionID}" + $"/resourceGroups/{this.fixture.ResourceGroup.Name}" + $"/providers/Microsoft.Storage/storageAccounts/{this.fixture.ResourceGroup.Name + suffix}" + $"/blobServices/default/containers/{this.fixture.ResourceGroup.Name + suffix}"; Assert.Equal(this.fixture.ResourceGroup.Name + suffix, storageTarget.Name); Assert.Equal(id, storageTarget.Id, ignoreCase: true); Assert.Equal("clfs", storageTarget.TargetType); Assert.Equal(clfsTarget, storageTarget.Clfs.Target); Assert.Equal("/junction" + suffix, storageTarget.Junctions[0].NamespacePath); Assert.Equal("/", storageTarget.Junctions[0].TargetPath); // Call an invalid DNSRefresh case. Models.SystemData systemData = new Models.SystemData("SDK", "Application", DateTime.UtcNow, "SDK", "Application", DateTime.UtcNow); StorageTarget st = new StorageTarget("clfs", "clfsStorageTarget", null, "StorageTarget", systemData: systemData); Models.SystemData sd = storageTarget.SystemData; testOutputHelper.WriteLine($"ST values createdBy {sd.CreatedBy}, createdByType {sd.CreatedByType}, createdAt {sd.CreatedAt}"); testOutputHelper.WriteLine($"ST values modifiedBy {sd.LastModifiedBy}, modifiedByType {sd.LastModifiedByType}, modifiedAt {sd.LastModifiedAt}"); CloudErrorException ex = new CloudErrorException(); ex = Assert.Throws <CloudErrorException>( () => client.StorageTargets.DnsRefresh(fixture.ResourceGroup.Name, fixture.Cache.Name, storageTarget.Name)); testOutputHelper.WriteLine($"Exception Message: {ex.Body.Error.Message}"); testOutputHelper.WriteLine($"Request: {ex.Request}"); testOutputHelper.WriteLine($"Response: {ex.Response}"); Assert.Contains("BadRequest", ex.Body.Error.Code); Microsoft.Rest.ValidationException rex = Assert.Throws <Microsoft.Rest.ValidationException>( () => client.StorageTargets.DnsRefresh(null, fixture.Cache.Name, storageTarget.Name)); testOutputHelper.WriteLine($"Exception Message: {rex.Message}"); Assert.Contains("'resourceGroupName' cannot be null", rex.Message); rex = Assert.Throws <Microsoft.Rest.ValidationException>( () => client.StorageTargets.DnsRefresh(fixture.ResourceGroup.Name, null, storageTarget.Name)); testOutputHelper.WriteLine($"Exception Message: {rex.Message}"); Assert.Contains("'cacheName' cannot be null", rex.Message); rex = Assert.Throws <Microsoft.Rest.ValidationException>( () => client.StorageTargets.DnsRefresh(fixture.ResourceGroup.Name, ".badcachename.", storageTarget.Name)); testOutputHelper.WriteLine($"Exception Message: {rex.Message}"); Assert.Contains("'cacheName' does not match expected pattern '^[-0-9a-zA-Z_]{1,80}$'", rex.Message); } }