Inheritance: CsvClassMap
Beispiel #1
0
        //[Ignore]
        public void GetText_Returns_UpdateText()
        {
            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 UpdatePlan(mapping, register);
            var text   = insert.CreatePlanParameter(func, person);

            text.SqlText.ToUpper().Should().Be("UPDATE PERSON SET NAME = @NAME, AGE = @AGE WHERE ID = @ID");
            text.Parameters.Count.Should().Be(3);
        }
Beispiel #2
0
        public void MapAttribute_Must_Be_Case_Insensitive()
        {
            var mapper = new PersonMap();
            mapper.ExecuteMapping();

            mapper.Executing(x => x.GetByFieldName("NOME")).NotThrows();
        }
Beispiel #3
0
        public void MapIdentifier_Must_Be_Case_Insensitive()
        {
            var mapper = new PersonMap();
            mapper.ExecuteMapping();

            mapper.Executing(x => x.GetByFieldName("id")).NotThrows();
        }
Beispiel #4
0
        public void ReadWrite()
        {
            var person = new Person() { Name = "duraid", Age = 35 };
            person.Addresses.Add(new Address() { Street = "Decelles", City = "Montreal" });
            person.Addresses.Add(new Address() { Street = "Lincoln", City = "Montreal" });
            var map = new PersonMap();

            var doc = new XDocument();
            
            using (var writer = doc.CreateWriter())
            {
                map.WriteXml(writer, person);
            }

            Person person2;
            using (var reader = doc.CreateReader())
            {
                person2 = map.ReadXml(reader);
            }

            Assert.AreEqual(person.Name, person2.Name);
            Assert.AreEqual(person.Age, person2.Age);
            Assert.AreEqual(2, person.Addresses.Count);
            person.Addresses.Where(a => a.Street == "Decelles" && a.City == "Montreal").Single();
            person.Addresses.Where(a => a.Street == "Lincoln" && a.City == "Montreal").Single();
        }
Beispiel #5
0
        //[Ignore]
        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)");
        }
Beispiel #6
0
        public void GetText_Returns_SelectText()
        {
            var mapping = new PersonMap();
            mapping.ExecuteMapping();

            var select = new QueryPlan(mapping, null, null);

            select.CreatePlanParameter().SqlText.ToUpper().Should().Be("SELECT ID, NAME, AGE FROM PERSON");
        }
Beispiel #7
0
        public void GetText_Returns_SelectText()
        {
            var mapping = new PersonMap();

            mapping.ExecuteMapping();

            var select = new QueryPlan(mapping, null, null);

            select.CreatePlanParameter().SqlText.ToUpper().Should().Be("SELECT ID, NAME, AGE FROM PERSON");
        }
Beispiel #8
0
 protected override void OnModelCreating(ModelBuilder builder)
 {
     UserMap.Configure(builder);
     PersonMap.Configure(builder);
     PersonCheckListItemMap.Configure(builder);
     PersonCheckListMap.Configure(builder);
     QuizMap.Configure(builder);
     QuestionMap.Configure(builder);
     AnswerMap.Configure(builder);
     TopicCategoryMap.Configure(builder);
     TopicMap.Configure(builder);
     SupportingScriptureMap.Configure(builder);
     PersonAnswerMap.Configure(builder);
 }
Beispiel #9
0
        public ActionResult RegisterPerson([FromBody] PersonMap personDto)
        {
            MapFields maps = new MapFields();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception)
            {
            }
            return(Ok(maps.CreatePerson(personDto)));
        }
        public void Simple_Query_Translate()
        {
            var container = new NinjectContainer();
            var map = container.Resolve<IMappingManager>();
            var mapper = new PersonMap();
            mapper.ExecuteMapping();
            map.Register(mapper.MappedType, mapper);

            var query = new Query<Person>();
            query.Where(x => x.Name).Equal("Alaor").And(x => x.Age).GreaterThan(18).And(x => x.Id).NotEqual(0);

            var translator = new QueryTranslator(map);
            var result = translator.Translate(query);

            result.SqlText.Trim().ToUpper().Should().Be("NAME = @PARAMETER_0 AND AGE > @PARAMETER_1 AND ID <> @PARAMETER_2");
            result.Parameters.Count.Should().Be(3);
        }
        public void Simple_Query_Translate()
        {
            var container = new NinjectContainer();
            var map       = container.Resolve <IMappingManager>();
            var mapper    = new PersonMap();

            mapper.ExecuteMapping();
            map.Register(mapper.MappedType, mapper);

            var query = new Query <Person>();

            query.Where(x => x.Name).Equal("Alaor").And(x => x.Age).GreaterThan(18).And(x => x.Id).NotEqual(0);

            var translator = new QueryTranslator(map);
            var result     = translator.Translate(query);

            result.SqlText.Trim().ToUpper().Should().Be("NAME = @PARAMETER_0 AND AGE > @PARAMETER_1 AND ID <> @PARAMETER_2");
            result.Parameters.Count.Should().Be(3);
        }
Beispiel #12
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)");
        }
Beispiel #13
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");
        }
Beispiel #14
0
        private Task<int?> SaveLeader( int arenaLeaderPersonId )
        {
            var tcs = new TaskCompletionSource<int?>();
            var PersonMap = new PersonMap( ConnectionInfo, Service );

            PersonMap.ExportAttemptCompleted += ( o, e ) => tcs.SetResult( e.RockIdentifier );
            PersonMap.ExportRecord( arenaLeaderPersonId.ToString() );

            return tcs.Task;
        }