public void GetId_FixedConvention_GetsIdAsExpected()
 {
     var attrib = new DbIdConventionAttribute("Id");
     Guid id = Guid.NewGuid();
     var entity = new Entity {Id = id};
     Assert.AreEqual(id, attrib.GetId(entity));
 }
Exemplo n.º 2
0
        private DbIdConventionAttribute GetIdAttribute(object entity)
        {
            DbIdConventionAttribute attrib;

            if (idConventions.ContainsKey(entity.GetType().Name))
            {
                attrib = idConventions[entity.GetType().Name];
            }
            else if (idConventions.ContainsKey(NULLKEY))
            {
                attrib = idConventions[NULLKEY];
            }
            else
            {
                attrib = new DbIdConventionAttribute("Id{0}");
            }
            return(attrib);
        }
 public void GetId_ConventionIsNull_ThrowsInvalidOperationException()
 {
     var attrib = new DbIdConventionAttribute(null);
     attrib.GetId(DateTime.Now);
 }