示例#1
0
        public void CustomSerializePropertyName()
        {
            var poco = new TestDepartment { Name = "test" };

            var entity = ObjectEntityMapper.ConvertObjectToEntity(poco);

            Assert.IsFalse(entity.Properties.ContainsKey("Name"));
            Assert.IsTrue(entity.Properties.ContainsKey("departmentName"));
        }
示例#2
0
        public void IgnoreProperty()
        {
            var poco = new TestDepartment { PhoneNumber = "555", Code = 123 };

            var entity = ObjectEntityMapper.ConvertObjectToEntity(poco);

            Assert.IsFalse(entity.Properties.ContainsKey("Code"));
            Assert.IsTrue(entity.Properties.ContainsKey("PhoneNumber"));
        }
示例#3
0
        public void ObjectToEntityWithEntityProperty()
        {
            var poco = new TestDepartment
            {
                Code = 123,
                Director = new TestPerson { FirstName = "Boss" }
            };

            var entity = ObjectEntityMapper.ConvertObjectToEntity(poco);

            var value = entity.Properties["Director"].Values[0].EntityValue;
            string firstName = value.Properties["FirstName"].Values[0].StringValue;

            Assert.AreEqual("Boss", firstName);
        }
示例#4
0
        public void StoreAndLookupObjectWithChildEntity()
        {
            var unique = Guid.NewGuid().ToString();

            var poco = new TestDepartment
            {
                Id = unique,
                Code = 123,
                Director = new TestPerson { FirstName = "Boss" }
            };

            using (var session = _datastore.OpenSession())
            {
                session.Store(poco);
                session.SaveChanges();

                var lookupPoco = session.Load<TestDepartment>(unique);

                Assert.AreEqual("Boss", lookupPoco.Director.FirstName);
            }
        }