public void ZAttributeTestC_BatchDeleteAttribute() { bool hasCallbackArrived = false; bool actualValue = false; bool expectedValue = true; SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { //Unhook from event. _client.OnSimpleDBResponse -= handler; BatchDeleteAttributesResponse response = args.Response as BatchDeleteAttributesResponse; if (null != response) { actualValue = true; } hasCallbackArrived = true; }; //Hook to event _client.OnSimpleDBResponse += handler; BatchDeleteAttributesRequest deleteRequest = new BatchDeleteAttributesRequest() { DomainName = _domainName_UnitTesting }; List<DeleteableItem> deleteItem = deleteRequest.Item; #region Commented //Commented because there was change in the property defination during resolving FxCop warning //List<Amazon.SimpleDB.Model.Attribute> itemA = new List<Amazon.SimpleDB.Model.Attribute>(); //itemA.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Subcategory").WithValue("Private Limited")); //List<Amazon.SimpleDB.Model.Attribute> itemB = new List<Amazon.SimpleDB.Model.Attribute>(); //itemB.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Size").WithValue("Large")); //deleteItem.Add(new DeleteableItem() { Attribute = itemA, ItemName = "ItemA" }); //deleteItem.Add(new DeleteableItem() { Attribute = itemB, ItemName = "ItemB" }); #endregion DeleteableItem item1 = new DeleteableItem { ItemName = "ItemA" }; item1.Attribute.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Subcategory").WithValue("Private Limited")); DeleteableItem item2 = new DeleteableItem { ItemName = "ItemB" }; item2.Attribute.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Size").WithValue("Large")); deleteItem.Add(item1); deleteItem.Add(item2); _client.BatchDeleteAttributes(deleteRequest); EnqueueConditional(() => hasCallbackArrived); EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue)); EnqueueTestComplete(); }
private void btnBatchDeleteAttributes_Click(object sender, RoutedEventArgs e) { SimpleDBResponseEventHandler<object, ResponseEventArgs> responseHandler = null; responseHandler = delegate(object senderOriginal, ResponseEventArgs args) { ISimpleDBResponse result = args.Response; SimpleDB.Client.OnSimpleDBResponse -= responseHandler; this.Dispatcher.BeginInvoke(() => { BatchDeleteAttributesResponse response = result as BatchDeleteAttributesResponse; if (null != response) { this.BatchDeleteMessage = "Batch attributes deleted successfully"; } else { AmazonSimpleDBException exception = result as AmazonSimpleDBException; if (null != exception) this.BatchDeleteMessage = "Error: " + exception.Message; } }); }; this.BatchDeleteMessage = "Please wait..."; SimpleDB.Client.OnSimpleDBResponse += responseHandler; BatchDeleteAttributesRequest deleteRequest = new BatchDeleteAttributesRequest() { DomainName = this.DomainName }; List<DeleteableItem> deleteItem = deleteRequest.Item; //List<Amazon.SimpleDB.Model.Attribute> attributeItem1 = new List<Amazon.SimpleDB.Model.Attribute>(); //List<Amazon.SimpleDB.Model.Attribute> attributeItem2 = new List<Amazon.SimpleDB.Model.Attribute>(); List<AttributeAndValue> aAndV1 = GetListAttributeAndValueFromString(this.AttributesAndValuesToPut); DeleteableItem item1 = new DeleteableItem { ItemName = "OneAttribute" }; DeleteableItem item2 = new DeleteableItem { ItemName = "TwoAttribute" }; int index = 0; foreach (var item in aAndV1) { if (index <= aAndV1.Count / 2) item1.Attribute.Add(new Amazon.SimpleDB.Model.Attribute().WithName(item.Attribute).WithValue(item.Value)); else item2.Attribute.Add(new Amazon.SimpleDB.Model.Attribute().WithName(item.Attribute).WithValue(item.Value)); index++; } //attributeItem1.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Category").WithValue("Clothes")); //attributeItem1.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Subcategory").WithValue("Sweater")); //attributeItem2.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Size").WithValue("Small")); //attributeItem2.Add(new Amazon.SimpleDB.Model.Attribute().WithName("Color").WithValue("Siamese")); #region Commented //Commented because of changes in the Attribute property definition change during resolving FxCop warnings. //deleteItem.Add(new DeleteableItem() { Attribute = attributeItem1, ItemName = "OneAttribute" }); //deleteItem.Add(new DeleteableItem() { Attribute = attributeItem2, ItemName = "TwoAttribute" }); #endregion Commented deleteItem.Add(item1); deleteItem.Add(item2); SimpleDB.Client.BatchDeleteAttributes(deleteRequest); }