Beispiel #1
0
        private ITestCluster SetupSessionAndCluster(int nodes, Dictionary <string, string> replication = null)
        {
            ITestCluster testCluster = TestClusterManager.GetTestCluster(nodes);

            _session = testCluster.Session;
            _ksName  = TestUtils.GetUniqueKeyspaceName();
            _session.CreateKeyspace(_ksName, replication);
            TestUtils.WaitForSchemaAgreement(_session.Cluster);
            _session.ChangeKeyspace(_ksName);
            _table = new Table <ManyDataTypesEntity>(_session, new MappingConfiguration());
            _table.Create();
            _defaultPocoList   = ManyDataTypesEntity.GetDefaultAllDataTypesList();
            _preparedStatement = _session.Prepare(_preparedInsertStatementAsString);
            foreach (var manyDataTypesEntity in _defaultPocoList)
            {
                _session.Execute(GetBoundInsertStatementBasedOnEntity(manyDataTypesEntity));
            }

            return(testCluster);
        }
Beispiel #2
0
        ///////////////////////////////////////
        ///  Test Helper Methods
        ///////////////////////////////////////

        private void DoBatchInsertTest(ConsistencyLevel expectedConsistencyLevel)
        {
            // Add a few more records via batch statement
            BatchStatement batch = new BatchStatement();

            batch.SetConsistencyLevel(expectedConsistencyLevel);
            var addlPocoList = ManyDataTypesEntity.GetDefaultAllDataTypesList();

            foreach (var manyDataTypesPoco in addlPocoList)
            {
                string          simpleStatementStr = GetSimpleStatementInsertString(manyDataTypesPoco);
                SimpleStatement simpleStatement    = new SimpleStatement(simpleStatementStr);
                batch.Add(simpleStatement);
            }

            // Validate Results
            var result = _session.Execute(batch);

            Assert.AreEqual(expectedConsistencyLevel, result.Info.AchievedConsistency);
            int totalExpectedRecords = _defaultPocoList.Count + addlPocoList.Count;

            result = _session.Execute(_defaultSelectStatement);
            Assert.AreEqual(totalExpectedRecords, result.GetRows().ToList().Count);
        }