Exemplo n.º 1
0
        public void SetNameOnlyParametersFromObject()
        {
            var collection = new CqlParameterCollection();
            collection.Add("id", CqlType.Int);
            collection.Add("value", CqlType.Text);
            collection.Add("ignored", CqlType.Blob);

            var a = new A {Id = 1, Ignored = new byte[] {1, 2}, Value = "Hello!"};

            collection.Set(a);

            Assert.AreEqual(a.Id, collection["id"].Value);
            Assert.AreEqual(a.Value, collection["value"].Value);
            Assert.IsNull(collection["ignored"].Value);
        }
Exemplo n.º 2
0
        public void SetParametersFromAnonymousObject()
        {
            var collection = new CqlParameterCollection
            {
                {"test.id", CqlType.Int},
                {"test.value", CqlType.Text},
                {"test.value2", CqlType.Blob},
                {"test.map", CqlType.CreateType(CqlTypeCode.Map, CqlType.Text, CqlType.Boolean)}
            };
            collection.Fixate();

            var a = new {Id = 1, value2 = new byte[] {1, 2}, Value = "Hello!"};

            collection.Set(a);

            Assert.AreEqual(a.Id, collection["test.id"].Value);
            Assert.AreEqual(a.Value, collection["test.value"].Value);
            Assert.AreEqual(a.value2, collection["test.value2"].Value);
            Assert.IsNull(collection[3].Value);
        }
Exemplo n.º 3
0
        public void SetParametersFromTwoObjects()
        {
            var collection = new CqlParameterCollection();
            collection.Add("test.id", CqlType.Int);
            collection.Add("test.value", CqlType.Text);
            collection.Add("test.ignored", CqlType.Blob);
            collection.Add("test2.id", CqlType.Int);
            collection.Add("test2.value", CqlType.Text);
            collection.Add("test2.value2", CqlType.Blob);
            collection.Fixate();

            var a = new A {Id = 1, Ignored = new byte[] {1, 2}, Value = "Hello!"};
            var b = new B {Id = 2, Value2 = new byte[] {3, 4}, Value = "World!"};

            collection.Set(a);
            collection.Set(b);

            Assert.AreEqual(a.Id, collection["test.id"].Value);
            Assert.AreEqual(a.Value, collection["test.value"].Value);
            Assert.IsNull(collection["test.ignored"].Value);
            Assert.AreEqual(b.Id, collection["test2.id"].Value);
            Assert.AreEqual(b.Value, collection["test2.value"].Value);
            Assert.AreEqual(b.Value2, collection["test2.value2"].Value);
        }