src/Cassandra.IntegrationTests/Linq/LinqTable/CreateTable.cs
/// <summary>
/// Successfully create two tables with the same name in two different keyspaces using the method Create
/// Do not manually change the session to use the different keyspace
/// </summary>
Successfully create two tables with the same name in two different keyspaces using the method Create
Do not manually change the session to use the different keyspace
Successfully create two tables with the same name in two different keyspaces using the method Create Do not manually change the session to use the different keyspace
[Test, TestCassandraVersion(2, 0)]
        public void TableCreate_Create_TwoTablesSameName_TwoKeyspacesDifferentNames_KeyspaceOverride()
        {
            var sharedTableName = typeof (AllDataTypesEntity).Name;
            var mappingConfig = new MappingConfiguration().Define(new Map<AllDataTypesEntity>().TableName(sharedTableName).CaseSensitive().PartitionKey(c => c.StringType));
            var table1 = new Table<AllDataTypesEntity>(_session, mappingConfig);
            table1.Create();
            Assert.IsTrue(TestUtils.TableExists(_session, _uniqueKsName, sharedTableName, true)); 
            WriteReadValidate(table1);
            var newUniqueKsName = TestUtils.GetUniqueKeyspaceName();
            _session.CreateKeyspace(newUniqueKsName);
            Assert.AreNotEqual(_uniqueKsName, newUniqueKsName);
            var table2 = new Table<AllDataTypesEntity>(_session, mappingConfig, sharedTableName, newUniqueKsName);
            table2.Create();
            Assert.IsTrue(TestUtils.TableExists(_session, newUniqueKsName, sharedTableName, true)); 
            WriteReadValidate(table2);
            _session.ChangeKeyspace(_uniqueKsName);
            WriteReadValidate(table1);
            _session.ChangeKeyspace(newUniqueKsName);
            WriteReadValidate(table2);
        }
[ Test , TestCassandraVersion ( 2 , 0 ) ] public void TableCreate_Create_TwoTablesSameName_TwoKeyspacesDifferentNames_KeyspaceOverride ( ) { var sharedTableName = typeof ( AllDataTypesEntity ) . Name ; var mappingConfig = new MappingConfiguration ( ) . Define ( new Map < AllDataTypesEntity > ( ) . TableName ( sharedTableName ) . CaseSensitive ( ) . PartitionKey ( c => c . StringType ) ) ; var table1 = new Table < AllDataTypesEntity > ( _session , mappingConfig ) ; table1 . Create ( ) ; Assert . IsTrue ( TestUtils . TableExists ( _session , _uniqueKsName , sharedTableName , true ) ) ; WriteReadValidate ( table1 ) ; var newUniqueKsName = TestUtils . GetUniqueKeyspaceName ( ) ; _session . CreateKeyspace ( newUniqueKsName ) ; Assert . AreNotEqual ( _uniqueKsName , newUniqueKsName ) ; var table2 = new Table < AllDataTypesEntity > ( _session , mappingConfig , sharedTableName , newUniqueKsName ) ; table2 . Create ( ) ; Assert . IsTrue ( TestUtils . TableExists ( _session , newUniqueKsName , sharedTableName , true ) ) ; WriteReadValidate ( table2 ) ; _session . ChangeKeyspace ( _uniqueKsName ) ; WriteReadValidate ( table1 ) ; _session . ChangeKeyspace ( newUniqueKsName ) ; WriteReadValidate ( table2 ) ; }
Successfully create two tables with the same name in two different keyspaces using the method Create
Do not manually change the session to use the different keyspace
Successfully create two tables with the same name in two different keyspaces using the method Create Do not manually change the session to use the different keyspace
// Setup first table // Create second table with same name in new keyspace // also use ChangeKeyspace and validate client functionality