public void Create() { try { rt.srz.model.srz.QueryResponseItemize entity = CreateNew(); object result = manager.Save(entity); Assert.IsNotNull(result); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public static QueryResponseItemize CreateNew(int depth = 0) { rt.srz.model.srz.QueryResponseItemize entity = new rt.srz.model.srz.QueryResponseItemize(); // You may need to maually enter this key if there is a constraint violation. entity.Id = System.Guid.NewGuid(); using (rt.srz.business.manager.IQueryResponseManager queryResponseManager = ObjectFactory.GetInstance <IQueryResponseManager>()) { var all = queryResponseManager.GetAll(1); QueryResponse entityRef = null; if (all.Count > 0) { entityRef = all[0]; } if (entityRef == null && depth < 3) { depth++; entityRef = QueryResponseTests.CreateNew(depth); ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef); } entity.QueryResponse = entityRef; } using (rt.srz.business.manager.ISearchKeyTypeManager searchKeyTypeManager = ObjectFactory.GetInstance <ISearchKeyTypeManager>()) { var all = searchKeyTypeManager.GetAll(1); SearchKeyType entityRef = null; if (all.Count > 0) { entityRef = all[0]; } if (entityRef == null && depth < 3) { depth++; entityRef = SearchKeyTypeTests.CreateNew(depth); ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef); } entity.KeyType = entityRef; } return(entity); }
public void Read() { try { rt.srz.model.srz.QueryResponseItemize entityA = CreateNew(); manager.Save(entityA); rt.srz.model.srz.QueryResponseItemize entityB = manager.GetById(entityA.Id); Assert.AreEqual(entityA, entityB); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Delete() { try { rt.srz.model.srz.QueryResponseItemize entityC = CreateNew(); manager.Save(entityC); manager.Session.GetISession().Flush(); manager.Session.GetISession().Clear(); rt.srz.model.srz.QueryResponseItemize entity = GetFirstQueryResponseItemize(); manager.Delete(entity); entity = manager.GetById(entity.Id); Assert.IsNull(entity); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }