private AllDataTypesNoColumnMeta WriteReadValidateUsingSessionBatch(Table <AllDataTypesNoColumnMeta> table)
        {
            Batch batch = _session.CreateBatch();
            AllDataTypesNoColumnMeta expectedDataTypesRow = AllDataTypesNoColumnMeta.GetRandomInstance();
            string uniqueKey = expectedDataTypesRow.StringType;

            batch.Append(table.Insert(expectedDataTypesRow));
            batch.Execute();

            List <AllDataTypesNoColumnMeta> listOfAllDataTypesObjects = (from x in table where x.StringType.Equals(uniqueKey) select x).Execute().ToList();

            Assert.NotNull(listOfAllDataTypesObjects);
            Assert.AreEqual(1, listOfAllDataTypesObjects.Count);
            AllDataTypesNoColumnMeta actualDataTypesRow = listOfAllDataTypesObjects.First();

            expectedDataTypesRow.AssertEquals(actualDataTypesRow);
            return(expectedDataTypesRow);
        }
        private AllDataTypesNoColumnMeta WriteReadValidateUsingTableMethods(Table <AllDataTypesNoColumnMeta> table)
        {
            AllDataTypesNoColumnMeta expectedDataTypesRow = AllDataTypesNoColumnMeta.GetRandomInstance();
            string uniqueKey = expectedDataTypesRow.StringType;

            // insert record
            _session.Execute(table.Insert(expectedDataTypesRow));

            // select record
            List <AllDataTypesNoColumnMeta> listOfAllDataTypesObjects = (from x in table where x.StringType.Equals(uniqueKey) select x).Execute().ToList();

            Assert.NotNull(listOfAllDataTypesObjects);
            Assert.AreEqual(1, listOfAllDataTypesObjects.Count);
            AllDataTypesNoColumnMeta actualDataTypesRow = listOfAllDataTypesObjects.First();

            expectedDataTypesRow.AssertEquals(actualDataTypesRow);
            return(expectedDataTypesRow);
        }
예제 #3
0
        public void TableCreate_Create_EntityTypeWithoutColumnNameMeta()
        {
            // Test
            MappingConfiguration mappingConfig = new MappingConfiguration();

            mappingConfig.MapperFactory.PocoDataFactory.AddDefinitionDefault(typeof(AllDataTypesNoColumnMeta),
                                                                             () => LinqAttributeBasedTypeDefinition.DetermineAttributes(typeof(AllDataTypesNoColumnMeta)));
            Table <AllDataTypesNoColumnMeta> table = new Table <AllDataTypesNoColumnMeta>(_session, mappingConfig);

            table.Create();
            AllDataTypesNoColumnMeta expectedAllDataTypesNoColumnMetaEntity = WriteReadValidate(table);

            // Do regular CQL query, validate that correct columns names are available as RowSet keys
            string cql = string.Format("Select * from \"{0}\".\"{1}\" where \"{2}\"='{3}'", _uniqueKsName, table.Name, "StringType",
                                       expectedAllDataTypesNoColumnMetaEntity.StringType);
            List <Row> listOfAllDataTypesObjects = _session.Execute(cql).GetRows().ToList();

            Assert.AreEqual(1, listOfAllDataTypesObjects.Count);
            Row row = listOfAllDataTypesObjects[0];

            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.BooleanType, row["BooleanType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.DateTimeOffsetType.ToString(), ((DateTimeOffset)row["DateTimeOffsetType"]).ToString());
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.DateTimeType.ToString("US"), ((DateTimeOffset)row["DateTimeType"]).ToString("US"));
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.DecimalType, row["DecimalType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.DictionaryStringLongType, row["DictionaryStringLongType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.DictionaryStringStringType, row["DictionaryStringStringType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.DoubleType, row["DoubleType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.FloatType, row["FloatType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.GuidType, row["GuidType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.Int64Type, row["Int64Type"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.IntType, row["IntType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.ListOfGuidsType, row["ListOfGuidsType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.ListOfStringsType, row["ListOfStringsType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.NullableIntType, row["NullableIntType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.NullableTimeUuidType, row["NullableTimeUuidType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.StringType, row["StringType"]);
            Assert.AreEqual(expectedAllDataTypesNoColumnMetaEntity.TimeUuidType.ToGuid(), (Guid)row["TimeUuidType"]);
        }