Ejemplo n.º 1
0
        public void TestGetNullOrEmptyNameThrowsException()
        {
            var tuple = new IgniteTuple {
                ["Foo"] = 1
            };

            var ex = Assert.Throws <IgniteClientException>(() => tuple.GetOrdinal(string.Empty));

            Assert.AreEqual("Column name can not be null or empty.", ex !.Message);

            ex = Assert.Throws <IgniteClientException>(() => tuple.GetOrdinal(null !));
            Assert.AreEqual("Column name can not be null or empty.", ex !.Message);

            ex = Assert.Throws <IgniteClientException>(() =>
            {
                var unused = tuple[string.Empty];
            });
            Assert.AreEqual("Column name can not be null or empty.", ex !.Message);

            ex = Assert.Throws <IgniteClientException>(() =>
            {
                var unused = tuple[null !];
            });
Ejemplo n.º 2
0
        public void TestCreateUpdateRead()
        {
            IIgniteTuple tuple = new IgniteTuple();

            Assert.AreEqual(0, tuple.FieldCount);

            tuple["foo"] = 1;
            tuple["bar"] = Guid.Empty;

            Assert.AreEqual(2, tuple.FieldCount);

            Assert.AreEqual(1, tuple["foo"]);
            Assert.AreEqual(Guid.Empty, tuple["bar"]);

            Assert.AreEqual(1, tuple[0]);
            Assert.AreEqual(Guid.Empty, tuple[1]);

            Assert.AreEqual("FOO", tuple.GetName(0));
            Assert.AreEqual("BAR", tuple.GetName(1));

            Assert.AreEqual(0, tuple.GetOrdinal("foo"));
            Assert.AreEqual(0, tuple.GetOrdinal("Foo"));
            Assert.AreEqual(0, tuple.GetOrdinal("FOO"));
            Assert.AreEqual(0, tuple.GetOrdinal("\"FOO\""));
            Assert.AreEqual(-1, tuple.GetOrdinal("\"Foo\""));
            Assert.AreEqual(1, tuple.GetOrdinal("bar"));

            tuple[0]     = 2;
            tuple["bar"] = "x";
            tuple["qux"] = null;

            Assert.AreEqual(3, tuple.FieldCount);

            Assert.AreEqual(2, tuple["foo"]);
            Assert.AreEqual("x", tuple[1]);
            Assert.IsNull(tuple[2]);
        }