private static T ConvertTo <T>(CassandraObject type)
        {
            if (type == null)
            {
                return(default(T));
            }

            return(type.GetValue <T>());
        }
示例#2
0
        public void CassandraType_Cast()
        {
            //arrange
            var expected = _mapType;

            //act
            MapType <LongType, UUIDType> actualType = expected;
            CassandraObject actual = actualType;

            //assert
            Assert.True(expected.SequenceEqual(actual.GetValue <Dictionary <LongType, UUIDType> >()));
        }
示例#3
0
        public void Explicit_List_Cast()
        {
            //arrange
            List <int> expected = new List <int>()
            {
                1, 2, 3
            };
            SetType <IntegerType> actualType = SetType <IntegerType> .From(expected);

            //act
            CassandraObject actual       = actualType;
            var             actualValues = actual.GetValue <List <object> >();

            //assert
            Assert.True(expected.SequenceEqual(actualValues.Select(Convert.ToInt32)));
        }
示例#4
0
        public void Explicit_Dictionary_Cast()
        {
            //arrange
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "item1", 1 }, { "item2", 2 }, { "item3", 3 }
            };

            //act
            MapType <UTF8Type, IntegerType> actualType = MapType <UTF8Type, IntegerType> .From(expected);

            CassandraObject actual = actualType;

            //assert
            Assert.True(expected.SequenceEqual(actual.GetValue <Dictionary <string, int> >()));
        }