Ejemplo n.º 1
0
        public void TestBatchDeleteAttributes()
        {
            List<ReplaceableAttribute> list = new List<ReplaceableAttribute> ();
            list.Add (new ReplaceableAttribute ("Test", "Test", true));

            List<ReplaceableItem> items = new List<ReplaceableItem> ();
            ReplaceableItem item0 = new ReplaceableItem ("0", list);
            items.Add (item0);
            ReplaceableItem item1 = new ReplaceableItem ("1", list);
            items.Add (item1);

            BatchPutAttributesRequest request = new BatchPutAttributesRequest ("Test", items);
            BatchPutAttributesResponse response = Client.BatchPutAttributes (request).Result;
            Assert.AreEqual (HttpStatusCode.OK, response.HttpStatusCode);

            List<Attribute> list2 = new List<Attribute> ();
            list2.Add (new Attribute ("Test", "Test"));
            List<Item> items2 = new List<Item> ();
            items2.Add (new Item ("0", list2.ToArray ()));
            items2.Add (new Item ("1", list2.ToArray ()));

            BatchDeleteAttributesRequest request2 = new BatchDeleteAttributesRequest ("Test", items2);
            BatchDeleteAttributesResponse response2 = Client.BatchDeleteAttributes (request2).Result;
            Assert.AreEqual (HttpStatusCode.OK, response2.HttpStatusCode);
        }
        public void Configure(BatchPutAttributesRequest request)
        {
            base.Configure (request);
            for (int itemCount = 0; itemCount < request.ReplaceableItems.Count; itemCount++) {

                ReplaceableItem item = request.ReplaceableItems [itemCount];
                Arguments.Add ("Item." + (itemCount) + ".ItemName", item.ItemName);

                for (int attributeCount = 0; attributeCount < item.ReplaceableAttributes.Count; attributeCount++) {
                    ReplaceableAttribute attribute = item.ReplaceableAttributes [attributeCount];
                    Arguments.Add ("Item." + (itemCount) + ".Attribute." + (attributeCount) + ".Name", attribute.Name);
                    Arguments.Add ("Item." + (itemCount) + ".Attribute." + (attributeCount) + ".Value", attribute.Value);
                    if (attribute.Replace) {
                        Arguments.Add ("Item." + (itemCount) + ".Attribute." + (attributeCount) + ".Replace", "true");
                    }
                }
            }
        }
		public async Task<BatchPutAttributesResponse> BatchPutAttributes (BatchPutAttributesRequest request)
		{
			using (HttpClient Client = new HttpClient ()) {

				BatchPutAttributesRequestMarshaller marshaller = new BatchPutAttributesRequestMarshaller ();
				marshaller.Configure (request);

				HttpResponseMessage responseMessage;

				try {
					responseMessage = await Client.SendAsync (ConfigureClient (Client, marshaller));
				} catch (WebException e) {
					throw new AWSConnectionException (e);
				}

				BatchPutAttributtesResponseUnMarshaller unmarshaler = new BatchPutAttributtesResponseUnMarshaller ();
				unmarshaler.Configure (responseMessage);
				return unmarshaler.UnMarshal ();
			}
		}
Ejemplo n.º 4
0
        public void TestSelectRequest()
        {
            List<ReplaceableAttribute> list = new List<ReplaceableAttribute> ();
            list.Add (new ReplaceableAttribute ("Test", "true", true));

            List<ReplaceableItem> items = new List<ReplaceableItem> ();
            ReplaceableItem item0 = new ReplaceableItem ("0", list);
            items.Add (item0);
            ReplaceableItem item1 = new ReplaceableItem ("1", list);
            items.Add (item1);
            BatchPutAttributesRequest request = new BatchPutAttributesRequest ("Test", items);
            BatchPutAttributesResponse response = Client.BatchPutAttributes (request).Result;
            Assert.AreEqual (HttpStatusCode.OK, response.HttpStatusCode);

            SelectRequest request2 = new SelectRequest ("select * from Test where Test = 'true'", true);
            SelectResponse response2 = Client.Select (request2).Result;

            Assert.AreEqual ("Test", response2.SelectResult.Item [0].Attribute [0].Name);
            Assert.AreEqual ("true", response2.SelectResult.Item [0].Attribute [0].Value);
            Assert.AreEqual ("Test", response2.SelectResult.Item [1].Attribute [0].Name);
            Assert.AreEqual ("true", response2.SelectResult.Item [1].Attribute [0].Value);
            Assert.AreEqual (HttpStatusCode.OK, response2.HttpStatusCode);
        }