예제 #1
0
        public void CqlClientConfiguration_UseIndividualMappingClassType_StaticMappingClass()
        {
            var config = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
            var table  = new Table <ManyDataTypesPoco>(Session, config);

            table.CreateIfNotExists();

            VerifyQuery(CreateCqlCaseSensitive, 1);

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

            mapper.Insert(manyTypesInstance);

            VerifyBoundStatement(
                $"INSERT INTO \"{table.Name}\" ({ManyDataTypesPoco.GetCaseSensitiveColumnNamesStr()}) " +
                $"VALUES ({string.Join(", ", ManyDataTypesPoco.GetColumnNames().Select(_ => "?"))})",
                1,
                manyTypesInstance.GetParameters());

            var cqlSelect = $"SELECT * from \"{table.Name}\" where \"StringType\"='{manyTypesInstance.StringType}'";

            TestCluster.PrimeFluent(
                b => b.WhenQuery(cqlSelect)
                .ThenRowsSuccess(ManyDataTypesPoco.GetColumnsAndTypes(), r => r.WithRow(manyTypesInstance.GetParameters())));

            var instancesQueried = mapper.Fetch <ManyDataTypesPoco>(cqlSelect).ToList();

            ManyDataTypesPoco.AssertListEqualsList(new List <ManyDataTypesPoco> {
                manyTypesInstance
            }, instancesQueried);
        }
예제 #2
0
        public void CqlClientConfiguration_UseIndividualMappingGeneric_StaticMappingClass()
        {
            var config = new MappingConfiguration().Define(new ManyDataTypesPocoMappingCaseSensitive());
            var table  = new Table <ManyDataTypesPoco>(Session, config);

            Assert.AreNotEqual(table.Name, table.Name.ToLower()); // make sure the case sensitivity rule is being used
            table.CreateIfNotExists();

            VerifyQuery(CreateCqlCaseSensitive, 1);

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

            mapper.Insert(manyTypesInstance);

            VerifyBoundStatement(
                $"INSERT INTO \"{table.Name}\" ({ManyDataTypesPoco.GetCaseSensitiveColumnNamesStr()}) " +
                $"VALUES ({string.Join(", ", ManyDataTypesPoco.GetColumnNames().Select(_ => "?"))})",
                1,
                manyTypesInstance.GetParameters());

            TestCluster.PrimeFluent(
                b => b.WhenQuery(
                    $"SELECT {ManyDataTypesPoco.GetCaseSensitiveColumnNamesStr()} FROM \"{table.Name}\"")
                .ThenRowsSuccess(ManyDataTypesPoco.GetColumnsAndTypes(), r => r.WithRow(manyTypesInstance.GetParameters())));

            var instancesQueried = mapper.Fetch <ManyDataTypesPoco>().ToList();

            Assert.AreEqual(instancesQueried.Count, 1);
            manyTypesInstance.AssertEquals(instancesQueried[0]);
        }