Пример #1
0
        public static MessageStatement CreateNew(int depth = 0)
        {
            rt.srz.model.srz.MessageStatement entity = new rt.srz.model.srz.MessageStatement();

            // You may need to maually enter this key if there is a constraint violation.
            entity.Id = System.Guid.NewGuid();

            entity.Version = 48;

            using (rt.srz.business.manager.IConceptManager conceptManager = ObjectFactory.GetInstance <IConceptManager>())
            {
                var     all       = conceptManager.GetAll(1);
                Concept entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

                if (entityRef == null && depth < 3)
                {
                    depth++;
                    entityRef = ConceptTests.CreateNew(depth);
                    ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef);
                }

                entity.Type = entityRef;
            }

            using (rt.srz.business.manager.IMessageManager messageManager = 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);
        }
Пример #2
0
        public void Create()
        {
            try
            {
                rt.srz.model.srz.MessageStatement entity = CreateNew();

                object result = manager.Save(entity);

                Assert.IsNotNull(result);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Пример #3
0
        public void Read()
        {
            try
            {
                rt.srz.model.srz.MessageStatement entityA = CreateNew();
                manager.Save(entityA);

                rt.srz.model.srz.MessageStatement entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA, entityB);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Пример #4
0
        public void Delete()
        {
            try
            {
                rt.srz.model.srz.MessageStatement entityC = CreateNew();
                manager.Save(entityC);
                manager.Session.GetISession().Flush();
                manager.Session.GetISession().Clear();

                rt.srz.model.srz.MessageStatement entity = GetFirstMessageStatement();

                manager.Delete(entity);

                entity = manager.GetById(entity.Id);
                Assert.IsNull(entity);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Пример #5
0
        public void Update()
        {
            try
            {
                rt.srz.model.srz.MessageStatement entityC = CreateNew();
                manager.Save(entityC);
                manager.Session.GetISession().Flush();
                manager.Session.GetISession().Clear();

                rt.srz.model.srz.MessageStatement entityA = GetFirstMessageStatement();

                entityA.Version = 76;

                manager.Update(entityA);

                rt.srz.model.srz.MessageStatement entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA.Version, entityB.Version);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }