Beispiel #1
0
        public void Create()
        {
            try
            {
                rt.srz.model.srz.Batch entity = CreateNew();

                object result = manager.Save(entity);

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

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

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

                rt.srz.model.srz.Batch entity = GetFirstBatch();

                manager.Delete(entity);

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

                rt.srz.model.srz.Batch entityA = GetFirstBatch();

                entityA.FileName = "Test Test Test Test Test Test Test Test Test Test Test Test Test T";

                manager.Update(entityA);

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

                Assert.AreEqual(entityA.FileName, entityB.FileName);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Beispiel #5
0
        public static Batch CreateNew(int depth = 0)
        {
            rt.srz.model.srz.Batch entity = new rt.srz.model.srz.Batch();

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

            entity.FileName = "Test Test Test Test Test Test Test Test Test Test Test Test Tes";
            entity.Number   = default(Int16);

            using (rt.srz.business.manager.IConceptManager concept1Manager = ObjectFactory.GetInstance <IConceptManager>())
            {
                entity.CodeConfirm = 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.Subject = entityRef;
            }

            using (rt.srz.business.manager.IConceptManager concept3Manager = ObjectFactory.GetInstance <IConceptManager>())
            {
                var     all       = concept3Manager.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.IPeriodManager periodManager = ObjectFactory.GetInstance <IPeriodManager>())
            {
                entity.Period = null;
            }

            using (rt.srz.business.manager.IOrganisationManager organisation1Manager = ObjectFactory.GetInstance <IOrganisationManager>())
            {
                entity.Receiver = null;
            }

            using (rt.srz.business.manager.IOrganisationManager organisation2Manager = ObjectFactory.GetInstance <IOrganisationManager>())
            {
                entity.Sender = null;
            }

            return(entity);
        }