public void Create() { try { rt.fias.model.fias.House entity = CreateNew(); object result = manager.Save(entity); Assert.IsNotNull(result); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Read() { try { rt.fias.model.fias.House entityA = CreateNew(); manager.Save(entityA); rt.fias.model.fias.House entityB = manager.GetById(entityA.Id); Assert.AreEqual(entityA, entityB); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Delete() { try { rt.fias.model.fias.House entityC = CreateNew(); manager.Save(entityC); manager.Session.GetISession().Flush(); manager.Session.GetISession().Clear(); rt.fias.model.fias.House entity = GetFirstHouse(); manager.Delete(entity); entity = manager.GetById(entity.Id); Assert.IsNull(entity); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public void Update() { try { rt.fias.model.fias.House entityC = CreateNew(); manager.Save(entityC); manager.Session.GetISession().Flush(); manager.Session.GetISession().Clear(); rt.fias.model.fias.House entityA = GetFirstHouse(); entityA.Postalcode = "Test"; manager.Update(entityA); rt.fias.model.fias.House entityB = manager.GetById(entityA.Id); Assert.AreEqual(entityA.Postalcode, entityB.Postalcode); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
public static House CreateNew(int depth = 0) { rt.fias.model.fias.House entity = new rt.fias.model.fias.House(); // You may need to maually enter this key if there is a constraint violation. entity.Id = System.Guid.NewGuid(); entity.Postalcode = "T"; entity.Ifnsfl = "T"; entity.Terrifnsfl = "T"; entity.Ifnsul = "Tes"; entity.Terrifnsul = "T"; entity.Okato = "Test Test "; entity.Oktmo = "Test"; entity.Updatedate = System.DateTime.Now; entity.Housenum = "Test Test Te"; entity.Buildnum = "Te"; entity.Strucnum = "Test Te"; entity.Houseguid = System.Guid.NewGuid(); entity.Aoguid = System.Guid.NewGuid(); entity.Startdate = System.DateTime.Now; entity.Enddate = System.DateTime.Now; entity.Normdoc = System.Guid.NewGuid(); entity.Counter = 75; using (rt.fias.business.manager.IEstateStatusManager estateStatusManager = ObjectFactory.GetInstance <IEstateStatusManager>()) { var all = estateStatusManager.GetAll(1); EstateStatus entityRef = null; if (all.Count > 0) { entityRef = all[0]; } if (entityRef == null && depth < 3) { depth++; entityRef = EstateStatusTests.CreateNew(depth); ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef); } entity.ESTSTATUS = entityRef; } using (rt.fias.business.manager.IHouseStateStatusManager houseStateStatusManager = ObjectFactory.GetInstance <IHouseStateStatusManager>()) { var all = houseStateStatusManager.GetAll(1); HouseStateStatus entityRef = null; if (all.Count > 0) { entityRef = all[0]; } if (entityRef == null && depth < 3) { depth++; entityRef = HouseStateStatusTests.CreateNew(depth); ObjectFactory.GetInstance <ISessionFactory>().GetCurrentSession().Save(entityRef); } entity.STATSTATUS = entityRef; } using (rt.fias.business.manager.IStructureStatusManager structureStatusManager = ObjectFactory.GetInstance <IStructureStatusManager>()) { entity.STRSTATUS = null; } return(entity); }