public void Create() { try { rt.srz.model.srz.Error entity = CreateNew(); object result = manager.Save(entity); Assert.IsNotNull(result); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Read() { try { rt.srz.model.srz.Error entityA = CreateNew(); manager.Save(entityA); rt.srz.model.srz.Error entityB = manager.GetById(entityA.Id); Assert.AreEqual(entityA, entityB); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public static Error CreateNew(int depth = 0) { rt.srz.model.srz.Error entity = new rt.srz.model.srz.Error(); // You may need to maually enter this key if there is a constraint violation. entity.Id = System.Guid.NewGuid(); entity.Message1 = "Test Test "; entity.Code = "123"; entity.Repl = "Test Test "; using (rt.srz.business.manager.IConceptManager conceptManager = ObjectFactory.GetInstance <IConceptManager>()) { entity.Application = null; } using (rt.srz.business.manager.IMessageManager message2Manager = ObjectFactory.GetInstance <IMessageManager>()) { entity.Message = null; } using (rt.srz.business.manager.IStatementManager statementManager = ObjectFactory.GetInstance <IStatementManager>()) { var all = statementManager.GetAll(1); Statement entityRef = null; if (all.Count > 0) { entityRef = all[0]; } if (entityRef == null && depth < 3) { depth++; entityRef = StatementTests.CreateNew(depth); ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef); } entity.Statement = entityRef; } return(entity); }
public void Delete() { try { rt.srz.model.srz.Error entityC = CreateNew(); manager.Save(entityC); manager.Session.GetISession().Flush(); manager.Session.GetISession().Clear(); rt.srz.model.srz.Error entity = GetFirstError(); manager.Delete(entity); entity = manager.GetById(entity.Id); Assert.IsNull(entity); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Update() { try { rt.srz.model.srz.Error entityC = CreateNew(); manager.Save(entityC); manager.Session.GetISession().Flush(); manager.Session.GetISession().Clear(); rt.srz.model.srz.Error entityA = GetFirstError(); entityA.Message1 = "Test Test "; manager.Update(entityA); rt.srz.model.srz.Error entityB = manager.GetById(entityA.Id); Assert.AreEqual(entityA.Message1, entityB.Message1); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }