Exemplo n.º 1
0
        public static UserAction CreateNew(int depth = 0)
        {
            rt.srz.model.srz.UserAction entity = new rt.srz.model.srz.UserAction();


            entity.UserId = new Guid("01000000-0000-0000-0000-000000000000");

            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.Event = entityRef;
            }

            using (rt.srz.business.manager.IStatementManager statementManager = ObjectFactory.GetInstance <IStatementManager>())
            {
                entity.Statement = null;
            }

            return(entity);
        }
Exemplo n.º 2
0
        public void Create()
        {
            try
            {
                rt.srz.model.srz.UserAction entity = CreateNew();

                object result = manager.Save(entity);

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

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

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

                rt.srz.model.srz.UserAction entity = GetFirstUserAction();

                manager.Delete(entity);

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

                rt.srz.model.srz.UserAction entityA = GetFirstUserAction();

                entityA.UserId = System.Guid.NewGuid();

                manager.Update(entityA);

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

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