Example #1
0
        public void Create()
        {
            try
            {
                rt.fias.model.fias.AObject entity = CreateNew();

                object result = manager.Save(entity);

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

                rt.fias.model.fias.AObject entityB = manager.GetById(entityA.Id);

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

                rt.fias.model.fias.AObject entity = GetFirstAObject();

                manager.Delete(entity);

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

                rt.fias.model.fias.AObject entityA = GetFirstAObject();

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

                manager.Update(entityA);

                rt.fias.model.fias.AObject entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA.Aoguid, entityB.Aoguid);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
Example #5
0
        public static AObject CreateNew(int depth = 0)
        {
            rt.fias.model.fias.AObject entity = new rt.fias.model.fias.AObject();

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

            entity.Aoguid     = System.Guid.NewGuid();
            entity.Formalname = "Test Test ";
            entity.Regioncode = "T";
            entity.Autocode   = "T";
            entity.Areacode   = "Te";
            entity.Citycode   = "Te";
            entity.Ctarcode   = "T";
            entity.Placecode  = "T";
            entity.Streetcode = "Tes";
            entity.Extrcode   = "Test Test ";
            entity.Sextcode   = "T";
            entity.Offname    = "Test Test ";
            entity.Postalcode = "Test";
            entity.Ifnsfl     = "Tes";
            entity.Terrifnsfl = "Tes";
            entity.Ifnsul     = "Tes";
            entity.Terrifnsul = "T";
            entity.Okato      = "Test Test";
            entity.Oktmo      = "Test Te";
            entity.Updatedate = System.DateTime.Now;
            entity.Shortname  = "T";
            entity.Aolevel    = 28;
            entity.Parentguid = System.Guid.NewGuid();
            entity.Code       = "123";
            entity.Plaincode  = "Test Test T";
            entity.Startdate  = System.DateTime.Now;
            entity.Enddate    = System.DateTime.Now;
            entity.Normdoc    = System.Guid.NewGuid();
            entity.Livestatus = "T";

            using (rt.fias.business.manager.IActualStatusManager actualStatusManager = ObjectFactory.GetInstance <IActualStatusManager>())
            {
                var          all       = actualStatusManager.GetAll(1);
                ActualStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

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

                entity.ACTSTATUS = entityRef;
            }

            using (rt.fias.business.manager.ICenterStatusManager centerStatusManager = ObjectFactory.GetInstance <ICenterStatusManager>())
            {
                var          all       = centerStatusManager.GetAll(1);
                CenterStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

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

                entity.CENTSTATUS = entityRef;
            }

            using (rt.fias.business.manager.ICurrentStatusManager currentStatusManager = ObjectFactory.GetInstance <ICurrentStatusManager>())
            {
                var           all       = currentStatusManager.GetAll(1);
                CurrentStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

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

                entity.CURRSTATUS = entityRef;
            }

            using (rt.fias.business.manager.IAObjectManager aObjectMember1Manager = ObjectFactory.GetInstance <IAObjectManager>())
            {
                entity.NEXT = null;
            }

            using (rt.fias.business.manager.IAObjectManager aObjectMember2Manager = ObjectFactory.GetInstance <IAObjectManager>())
            {
                entity.PREV = null;
            }

            using (rt.fias.business.manager.IOperationStatusManager operationStatusManager = ObjectFactory.GetInstance <IOperationStatusManager>())
            {
                var             all       = operationStatusManager.GetAll(1);
                OperationStatus entityRef = null;
                if (all.Count > 0)
                {
                    entityRef = all[0];
                }

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

                entity.OPERSTATUS = entityRef;
            }

            return(entity);
        }