Example #1
0
        /// <summary>
        /// Execute mapping for baseic types
        /// </summary>
        public void MapTypes()
        {
            var wkbConverter = new WellKnownBinaryConverter(this._geometryFactory);
            var genericConverter = new GenericConverter();
            var int32Converter = new Int32Converter();

            var map = new TypeMap(DbType.Int32, typeof(uint), genericConverter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.Int32, typeof(int), int32Converter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.String, typeof(string), genericConverter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.DateTime, typeof(DateTime), genericConverter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.Binary, typeof(IMapPoint), wkbConverter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.Binary, typeof(ILineString), wkbConverter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.Binary, typeof(IPolygon), wkbConverter);
            this._typeRegister.Set(map);

            map = new TypeMap(DbType.Binary, typeof(IGeometry), wkbConverter);
            this._typeRegister.Set(map);
        }
Example #2
0
        public void GetText_Returns_InsertText()
        {
            var person = new Person();
            var mapping = new PersonMap();
            mapping.ExecuteMapping();

            var mapInt = new TypeMap(DbType.Int32,typeof(int),new GenericConverter());
            var mapString = new TypeMap(DbType.String,typeof(string),new GenericConverter());

            var mock = new Moq.Mock<ITypeRegister>();
            mock.Setup(x => x.Get(typeof (int))).Returns(mapInt);
            mock.Setup(x => x.Get(typeof(string))).Returns(mapString);

            var dbparam = new Moq.Mock<IDbDataParameter>();
            Func<IDbDataParameter> func = () => dbparam.Object;

            var register = mock.Object;

            var insert = new InsertPlan(mapping, register);
            var text = insert.CreatePlanParameter(func, person);

            text.SqlText.ToUpper().Should().Be("INSERT INTO PERSON (NAME, AGE) VALUES (@NAME, @AGE)");
        }
Example #3
0
        public void GetText_Returns_DeleteText()
        {
            var person = new Person();
            var mapping = new PersonMap();
            mapping.ExecuteMapping();

            var mapInt = new TypeMap(DbType.Int32, typeof(int), new GenericConverter());
            var mapString = new TypeMap(DbType.String, typeof(string), new GenericConverter());

            var mock = new Moq.Mock<ITypeRegister>();
            mock.Setup(x => x.Get(typeof(int))).Returns(mapInt);
            mock.Setup(x => x.Get(typeof(string))).Returns(mapString);

            var dbparam = new Moq.Mock<IDbDataParameter>();
            Func<IDbDataParameter> func = () => dbparam.Object;

            var register = mock.Object;

            var insert = new DeletePlan(mapping, register);
            var param = insert.CreatePlanParameter(func, person);

            param.SqlText.ToUpper().Should().Be("DELETE FROM PERSON WHERE ID = @ID");
        }