示例#1
0
        public void Create()
        {
            try
            {
                rt.srz.model.srz.SearchKeyType entity = CreateNew();

                object result = manager.Save(entity);

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

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

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

                rt.srz.model.srz.SearchKeyType entity = GetFirstSearchKeyType();

                manager.Delete(entity);

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

                rt.srz.model.srz.SearchKeyType entityA = GetFirstSearchKeyType();

                entityA.Code = "123";

                manager.Update(entityA);

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

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

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

            entity.Code                 = "123";
            entity.Name                 = "Test Test Test Test Test Test Test Test Test";
            entity.IsActive             = true;
            entity.FirstName            = true;
            entity.LastName             = true;
            entity.MiddleName           = true;
            entity.Birthday             = true;
            entity.Birthplace           = true;
            entity.Snils                = true;
            entity.DocumentType         = true;
            entity.DocumentSeries       = true;
            entity.DocumentNumber       = true;
            entity.Okato                = true;
            entity.PolisType            = true;
            entity.PolisSeria           = true;
            entity.PolisNumber          = true;
            entity.FirstNameLength      = default(Int16);
            entity.LastNameLength       = default(Int16);
            entity.MiddleNameLength     = default(Int16);
            entity.BirthdayLength       = default(Int16);
            entity.AddressStreet        = true;
            entity.AddressStreetLength  = default(Int16);
            entity.AddressHouse         = true;
            entity.AddressRoom          = true;
            entity.AddressStreet2       = true;
            entity.AddressStreetLength2 = default(Int16);
            entity.AddressHouse2        = true;
            entity.AddressRoom2         = true;
            entity.DeleteTwinChar       = true;
            entity.IdenticalLetters     = "Test Test ";
            entity.Recalculated         = true;
            entity.Enp       = true;
            entity.MainEnp   = true;
            entity.Weight    = 76;
            entity.Insertion = true;

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

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

            return(entity);
        }