Esempio n. 1
0
        public void QueryRequestTest3()
        {
            var query = DynamoExpression.FromExpression(Expression.Eq("name", "sortable"));

            var request = new DynamoQuery {
                TableName = "Libraries",
                KeyConditionExpression    = query.Text,
                ExpressionAttributeValues = query.AttributeValues,
                ExpressionAttributeNames  = query.AttributeNames,
                Limit = 1
            };

            Assert.Equal(@"{
  ""TableName"": ""Libraries"",
  ""KeyConditionExpression"": ""#name = :v0"",
  ""ExpressionAttributeNames"": {
    ""#name"": ""name""
  },
  ""ExpressionAttributeValues"": {
    "":v0"": {
      ""S"": ""sortable""
    }
  },
  ""Limit"": 1
}", request.ToJson().ToString());
        }
Esempio n. 2
0
        public void Expression2()
        {
            var expression = And(Eq("category", "shoes"), NotEq("price", 5));

            var de = DynamoExpression.FromExpression(expression);

            Assert.Equal("category = :v0 and price <> :v1", de.Text);

            Assert.Equal("shoes", de.AttributeValues[":v0"].Value);
            Assert.Equal(5, de.AttributeValues[":v1"].Value);
        }
Esempio n. 3
0
        public void Conjuction1()
        {
            var expression = Conjunction(Eq("category", "shoes"), Gt("price", 5), IsNull("deleted"));

            var de = DynamoExpression.FromExpression(expression);

            Assert.Equal("category = :v0 and price > :v1 and attribute_not_exists(deleted)", de.Text);

            Assert.Equal("shoes", de.AttributeValues[":v0"].Value);
            Assert.Equal(5, de.AttributeValues[":v1"].Value);
        }
Esempio n. 4
0
        public void Expression3()
        {
            var expression = And(Eq("category", "shoes"), Between("price", Constant(5), Constant(10)));

            var de = DynamoExpression.FromExpression(expression);

            Assert.Equal("category = :v0 and price between :v1 and :v2", de.Text);

            Assert.Equal("shoes", de.AttributeValues[":v0"].Value);
            Assert.Equal(5L, de.AttributeValues[":v1"].Value);
            Assert.Equal(10L, de.AttributeValues[":v2"].Value);
        }
Esempio n. 5
0
        public void Expression5()
        {
            var expression = And(Eq("name", "banana"), Eq("active", 1));

            var de = DynamoExpression.FromExpression(expression);

            Assert.Equal("#name = :v0 and active = :v1", de.Text);

            Assert.Equal("banana", de.AttributeValues[":v0"].Value);
            Assert.Equal(1, de.AttributeValues[":v1"].Value);
            Assert.Equal("name", de.AttributeNames["#name"].ToString());
        }