예제 #1
0
        public void CqlClientConfiguration_UseIndividualMappings_EmptyTypeDefinitionList()
        {
            // Setup
            var config = new MappingConfiguration().Define(new Map <ManyDataTypesPoco>()
                                                           .PartitionKey(c => c.StringType));
            var table = new Table <ManyDataTypesPoco>(_session, config);

            table.CreateIfNotExists();

            // validate default lower-casing
            Assert.AreNotEqual(typeof(ManyDataTypesPoco).Name.ToLower(), typeof(ManyDataTypesPoco).Name);
            Assert.AreNotEqual(table.Name.ToLower(), table.Name);
            Assert.AreEqual(typeof(ManyDataTypesPoco).Name.ToLower(), table.Name.ToLower());

            // Test
            var mapper = new Mapper(_session, config);
            ManyDataTypesPoco manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();

            mapper.Insert(manyTypesInstance);

            // Verify results
            string cqlSelect = string.Format("SELECT * from \"{0}\" where \"{1}\"='{2}'", table.Name.ToLower(), "stringtype", manyTypesInstance.StringType);

            ManyDataTypesPoco.KeepTryingSelectAndAssert(mapper, cqlSelect, new List <ManyDataTypesPoco>()
            {
                manyTypesInstance
            });
        }
예제 #2
0
        public void CqlClientConfiguration_UseIndividualMappings_StaticMappingClass()
        {
            var config = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
            var table  = new Table <ManyDataTypesPoco>(_session, config);

            table.CreateIfNotExists();

            var mapper = new Mapper(_session, config);
            ManyDataTypesPoco manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();

            mapper.Insert(manyTypesInstance);
            string cqlSelect = string.Format("SELECT * from \"{0}\" where \"{1}\"='{2}'", table.Name, "StringType", manyTypesInstance.StringType);

            ManyDataTypesPoco.KeepTryingSelectAndAssert(mapper, cqlSelect, new List <ManyDataTypesPoco>()
            {
                manyTypesInstance
            });
        }
예제 #3
0
        public void CqlClientConfiguration_UseIndividualMappingClassType_StaticMappingClass()
        {
            // Use separate keyspace to avoid interfering with other tests
            _uniqueKsName = TestUtils.GetUniqueKeyspaceName();
            _session.CreateKeyspace(_uniqueKsName);
            _session.ChangeKeyspace(_uniqueKsName);

            var config = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
            var table  = new Table <ManyDataTypesPoco>(_session, config);

            table.CreateIfNotExists();

            var mapper = new Mapper(_session, config);
            ManyDataTypesPoco manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();

            mapper.Insert(manyTypesInstance);
            string cqlSelect = string.Format("SELECT * from \"{0}\" where \"{1}\"='{2}'", table.Name, "StringType", manyTypesInstance.StringType);

            ManyDataTypesPoco.KeepTryingSelectAndAssert(mapper, cqlSelect, new List <ManyDataTypesPoco>()
            {
                manyTypesInstance
            });
        }
예제 #4
0
        public void CqlClientConfiguration_MappingOmitted()
        {
            // Setup
            var config = new MappingConfiguration().Define(new Map <ManyDataTypesPoco>()
                                                           .PartitionKey(c => c.StringType));
            var table = new Table <ManyDataTypesPoco>(_session, config);

            table.Create();

            // Test
            var mapper = new Mapper(_session, config);
            ManyDataTypesPoco manyTypesInstance = ManyDataTypesPoco.GetRandomInstance();

            mapper.Insert(manyTypesInstance);

            // Check results
            string cqlSelect = string.Format("SELECT * from \"{0}\" where \"{1}\"='{2}'", table.Name.ToLower(), "stringtype", manyTypesInstance.StringType);

            ManyDataTypesPoco.KeepTryingSelectAndAssert(mapper, cqlSelect, new List <ManyDataTypesPoco>()
            {
                manyTypesInstance
            });
        }