public void Configure(GetAttributesRequest request)
        {
            base.Configure (request);

            Arguments.Add ("ItemName", request.ItemName);

            if (request.AttributeNames != null) {
                for (int attributeCount = 0; attributeCount < request.AttributeNames.Count; attributeCount++) {
                    string attribute = request.AttributeNames [attributeCount];
                    Arguments.Add ("AttributeName." + (attributeCount), attribute);

                }
            }

            Arguments.Add ("ConsistentRead", request.ConsistentRead.ToString ().ToLower ());
        }
Пример #2
0
        public void TestSaveOrReplace()
        {
            //[SimpleDBDomain("TestDao")]
            bool result = DAO.CreateTable ().Result;
            Assert.AreEqual (true, result);

            TestEntity entity = new TestEntity ();
            entity.Id = 0;

            //[SimpleDBField("TestString")]
            entity.TestString = "TestString";
            //[SimpleDBField("TestBool")]
            entity.TestBool = false;
            //[SimpleDBField("TestByte",3)]
            entity.TestByte = 244;
            //[SimpleDBField("TestNegativeByte",3, 255)]
            entity.TestNegativeByte = -50;
            //[SimpleDBField("TestDecimal",5,1000)]
            entity.TestDecimal = 500;
            //[SimpleDBField("TestNegativeDecimal",5,1000)]
            entity.TestNegativeDecimal = -500;
            //[SimpleDBField("TestList")]
            entity.TestList = new List<string> (new[]{ "hello", "dolly", "the", "sheep" });
            bool result2 = DAO.SaveOrReplace (entity).Result;
            Assert.AreEqual (true, result2);

            GetAttributesRequest request = new GetAttributesRequest ("TestDao", "0", true);
            GetAttributesResponse response = Client.GetAttributes (request).Result;
            Assert.AreEqual (HttpStatusCode.OK, response.HttpStatusCode);

            Attribute TestString = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestString"));
            Assert.IsNotNull (TestString);
            Assert.AreEqual ("TestString", TestString.Value);

            Attribute TestBool = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestBool"));
            Assert.IsNotNull (TestBool);
            Assert.AreEqual ("False", TestBool.Value);

            Attribute TestByte = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestByte"));
            Assert.IsNotNull (TestByte);
            Assert.AreEqual ("244", TestByte.Value);

            Attribute TestNegativeByte = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestNegativeByte"));
            Assert.IsNotNull (TestNegativeByte);
            Assert.AreEqual ("205", TestNegativeByte.Value);

            Attribute TestDecimal = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestDecimal"));
            Assert.IsNotNull (TestDecimal);
            Assert.AreEqual ("01500", TestDecimal.Value);

            Attribute TestNegativeDecimal = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestNegativeDecimal"));
            Assert.IsNotNull (TestNegativeDecimal);
            Assert.AreEqual ("00500", TestNegativeDecimal.Value);

            Attribute TestList = Array.Find (response.GetAttributesResult, s => s.Name.Equals ("TestList"));
            Assert.IsNotNull (TestList);
            Assert.AreEqual ("[\"hello\",\"dolly\",\"the\",\"sheep\"]", TestList.Value);
        }
		public async Task<GetAttributesResponse> GetAttributes (GetAttributesRequest request)
		{
			using (HttpClient Client = new HttpClient ()) {

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

				HttpResponseMessage responseMessage;

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

				GetAttributtesResponseUnMarshaller unmarshaler = new GetAttributtesResponseUnMarshaller ();
				unmarshaler.Configure (responseMessage);
				return unmarshaler.UnMarshal ();
			}
		}
Пример #4
0
        public void TestDeleteAttributes()
        {
            List<ReplaceableAttribute> list = new List<ReplaceableAttribute> ();
            list.Add (new ReplaceableAttribute ("Test", "Test", true));
            PutAttributesRequest request = new PutAttributesRequest ("Test", "0", list);
            PutAttributesResponse response = Client.PutAttributes (request).Result;
            Assert.AreEqual (HttpStatusCode.OK, response.HttpStatusCode);

            GetAttributesRequest request2 = new GetAttributesRequest ("Test", "0", true);
            GetAttributesResponse response2 = Client.GetAttributes (request2).Result;
            Assert.AreEqual (HttpStatusCode.OK, response2.HttpStatusCode);
            Assert.AreEqual ("Test", response2.GetAttributesResult [0].Value);
            Assert.AreEqual ("Test", response2.GetAttributesResult [0].Name);

            DeleteAttributesRequest request3 = new DeleteAttributesRequest ("Test", "0");
            DeleteAttributesResponse response3 = Client.DeleteAttributes (request3).Result;
            Assert.AreEqual (HttpStatusCode.OK, response3.HttpStatusCode);

            GetAttributesRequest request4 = new GetAttributesRequest ("Test", "0", true);
            GetAttributesResponse response4 = Client.GetAttributes (request4).Result;
            Assert.AreEqual (HttpStatusCode.OK, response4.HttpStatusCode);
            Assert.AreEqual (0, response4.GetAttributesResult.Length);
        }