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

            return(type.GetValue <T>());
        }
Example #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> >()));
        }
Example #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)));
        }
Example #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> >()));
        }