Example #1
0
        public static Message CreateNew(int depth = 0)
        {
            rt.srz.model.srz.Message entity = new rt.srz.model.srz.Message();

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

            entity.IsCommit = true;
            entity.IsError  = true;

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

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

                entity.Batch = entityRef;
            }

            using (rt.srz.business.manager.IMessageManager messageMemberManager = ObjectFactory.GetInstance <IMessageManager>())
            {
                entity.DependsOnMessage = null;
            }

            using (rt.srz.business.manager.IConceptManager concept1Manager = ObjectFactory.GetInstance <IConceptManager>())
            {
                entity.Reason = null;
            }

            using (rt.srz.business.manager.IConceptManager concept2Manager = ObjectFactory.GetInstance <IConceptManager>())
            {
                var     all       = concept2Manager.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;
            }

            return(entity);
        }
Example #2
0
        public void Create()
        {
            try
            {
                rt.srz.model.srz.Message entity = CreateNew();

                object result = manager.Save(entity);

                Assert.IsNotNull(result);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Example #3
0
        public void Read()
        {
            try
            {
                rt.srz.model.srz.Message entityA = CreateNew();
                manager.Save(entityA);

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

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

                rt.srz.model.srz.Message entity = GetFirstMessage();

                manager.Delete(entity);

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

                rt.srz.model.srz.Message entityA = GetFirstMessage();

                entityA.IsCommit = true;

                manager.Update(entityA);

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

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