src/Cassandra.IntegrationTests/Mapping/Tests/FluentMapping.cs
/// <summary>
/// Validate Fluent Mapping default case sensitivity rules
/// </summary>
Validate Fluent Mapping default case sensitivity rules
Validate Fluent Mapping default case sensitivity rules
[Test]
        public void Attributes_FluentMapping_CaseSensitive()
        {
            var config = new MappingConfiguration().Define(new ClassWithCamelCaseNameMapping());
            var table = new Table<ClassWithCamelCaseName>(Session, config);
            table.Create();
            var cqlClient = new Mapper(Session, config);
            ClassWithCamelCaseName classWithCamelCaseName = new ClassWithCamelCaseName
            {
                SomePartitionKey = Guid.NewGuid().ToString(),
                IgnoredStringAttribute = Guid.NewGuid().ToString(),
            };
            cqlClient.Insert(classWithCamelCaseName);
            string cqlSelect = "SELECT * from \"" + typeof(ClassWithCamelCaseName).Name + "\"";
            List<ClassWithCamelCaseName> records = cqlClient.Fetch<ClassWithCamelCaseName>(cqlSelect).ToList();
            Assert.AreEqual(1, records.Count);
            Assert.AreEqual(classWithCamelCaseName.SomePartitionKey, records[0].SomePartitionKey);
            ClassWithCamelCaseName defaultInstance = new ClassWithCamelCaseName();
            Assert.AreEqual(defaultInstance.IgnoredStringAttribute, records[0].IgnoredStringAttribute);
            List<Row> rows = Session.Execute(cqlSelect).GetRows().ToList();
            Assert.AreEqual(1, rows.Count);
            Assert.AreEqual(classWithCamelCaseName.SomePartitionKey, rows[0].GetValue<string>("SomePartitionKey"));
            var ex = Assert.Throws<ArgumentException>(() => rows[0].GetValue<string>("IgnoredStringAttribute"));
            StringAssert.Contains("Column IgnoredStringAttribute not found", ex.Message);
        }
[ Test ] public void Attributes_FluentMapping_CaseSensitive ( ) { var config = new MappingConfiguration ( ) . Define ( new ClassWithCamelCaseNameMapping ( ) ) ; var table = new Table < ClassWithCamelCaseName > ( Session , config ) ; table . Create ( ) ; var cqlClient = new Mapper ( Session , config ) ; ClassWithCamelCaseName classWithCamelCaseName = new ClassWithCamelCaseName { SomePartitionKey = Guid . NewGuid ( ) . ToString ( ) , IgnoredStringAttribute = Guid . NewGuid ( ) . ToString ( ) , } ; cqlClient . Insert ( classWithCamelCaseName ) ; string cqlSelect = " \" " + typeof ( ClassWithCamelCaseName ) . Name + " \" " ; List < ClassWithCamelCaseName > records = cqlClient . Fetch < ClassWithCamelCaseName > ( cqlSelect ) . ToList ( ) ; Assert . AreEqual ( 1 , records . Count ) ; Assert . AreEqual ( classWithCamelCaseName . SomePartitionKey , records [ 0 ] . SomePartitionKey ) ; ClassWithCamelCaseName defaultInstance = new ClassWithCamelCaseName ( ) ; Assert . AreEqual ( defaultInstance . IgnoredStringAttribute , records [ 0 ] . IgnoredStringAttribute ) ; List < Row > rows = Session . Execute ( cqlSelect ) . GetRows ( ) . ToList ( ) ; Assert . AreEqual ( 1 , rows . Count ) ; Assert . AreEqual ( classWithCamelCaseName . SomePartitionKey , rows [ 0 ] . GetValue < string > ( " " ) ) ; var ex = Assert . Throws < ArgumentException > ( ( ) => rows [ 0 ] . GetValue < string > ( " " ) ) ; StringAssert . Contains ( " " , ex . Message ) ; }
Validate Fluent Mapping default case sensitivity rules
Validate Fluent Mapping default case sensitivity rules
// Get records using mapped object, validate that the value from Cassandra was ignored in favor of the default val // Query for the column that the Linq table create created, verify no value was uploaded to it