/// <summary> /// Konstruktor /// </summary> /// <param name="cadastre">katastar kojemu pripada katastarska cestica</param> /// <param name="numberOfCadastralParticle">broj katastarske cestice</param> /// <param name="surfaceArea">povrsina katastarske cestice</param> /// <param name="description">opis katastarske cestice</param> public CadastralParticle(Cadastre cadastre, string numberOfCadastralParticle, decimal surfaceArea, string description) { this.cadastre = cadastre; this.numberOfCadastralParticle = numberOfCadastralParticle; this.surfaceArea = surfaceArea; this.description = description; }
public void Can_Save_LandRegistry() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LandRegistriesNHRepository landRegistriesNhRepository = new LandRegistriesNHRepository(SessionFactory); // Act LandRegistry fetchedLandRegistry; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(cadastre); landRegistriesNhRepository.SaveOrUpdate(landRegistry); tx.Commit(); } using (var tx = session.BeginTransaction()) { fetchedLandRegistry = landRegistriesNhRepository.GetByNumberOfCadastralParticle(cadastralParticle.NumberOfCadastralParticle); tx.Commit(); } } // Assert Assert.AreEqual(landRegistry, fetchedLandRegistry, "LandRegistries aren't equal"); Assert.IsTrue(fetchedLandRegistry.PartitionSpaces.Count == 1, "LandRegistry haven't exactly one partition space."); }
public void Can_Read_Cadastre_From_DB() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Črnomerec", "335266", city); CadastresNHRepository cadastresNhRepository = new CadastresNHRepository(SessionFactory); // Act Cadastre cadastreFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(cadastre); tx.Commit(); } using (var tx = session.BeginTransaction()) { cadastreFromDb = cadastresNhRepository.GetById(1); tx.Commit(); } } // Assert Assert.AreEqual(cadastreFromDb, cadastre, "Two Cadastre entities aren't equal."); }
public void Can_Save_Bill_To_Db() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime") { Address = new Address("Ulica", "1", city) }; var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime") { NumberOfBankAccount = "123456", Address = new Address("Ulica", "2", city) }; BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; Bill bill = new Bill(legalPerson, building.Reserve, "opis plaćanja", 23) { ReferenceNumber = "123" }; bill.AddBillItem(new BillItem(1, 12.3m, "Opis")); IBillsRepository billsRepository = new BillsNHRepository(SessionFactory); // Act using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); session.Save(building); billsRepository.SaveOrUpdate(bill); transaction.Commit(); } } IList<Bill> billsFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { billsFromDb = billsRepository.GetAll().ToList(); transaction.Commit(); } } // Assert Assert.IsTrue(billsFromDb.Count == 1, "No Bill from database."); }
public static Cadastre getCadastre() { Cadastre cadastreForMock = new Cadastre("Trešnjevka", "12354", getCity()); Mock<ICadastresRepository> cadastresRepositoryMock = new Mock<ICadastresRepository>(); cadastresRepositoryMock.Setup(x => x.GetByMbr("12354")).Returns(cadastreForMock); return cadastresRepositoryMock.Object.GetByMbr("12345"); }
public void Can_Save_Maintenance_To_DB() { // Arrange var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); MaintenanceRequest maintenanceRequest = new MaintenanceRequest( person , "Kvar na grijanju" , "Grijanje ne radi" , "Prvi kat, stan 2"); City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime"); BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; RepairService repairService = new RepairService("Popravak grijanja"); Maintenance maintenance = new Maintenance(maintenanceRequest, Urgency.Normal, repairService, building); IMaintenancesRepository maintenancesRepository = new MaintenancesNHRepository(SessionFactory); // Act IList<Maintenance> maintenancesFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(person); session.Save(city); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); session.Save(building); session.Save(repairService); maintenancesRepository.SaveOrUpdate(maintenance); tx.Commit(); } using (var tx = session.BeginTransaction()) { maintenancesFromDb = maintenancesRepository.GetAll().ToList(); tx.Commit(); } } // Assert Assert.IsTrue(maintenancesFromDb.Count == 1, "No Maintenance from database."); }
public void Can_Read_Reserve_From_Db() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime") { NumberOfBankAccount = "12332213", Address = new Address("dsa", "2", city) }; BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; Bill bill = new Bill(legalPerson, building.Reserve, "račun", 23) { ReferenceNumber = "123" }; building.Reserve.AddBillForPayment(bill); // Act using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(city); session.Save(cadastre); session.Save(person); session.Save(landRegistry); session.Save(legalPerson); session.Save(buildingManager); session.Save(building); transaction.Commit(); } } IReservesRepository reservesRepository = new ReservesNHRepository(SessionFactory); IList<Reserve> reservesFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { reservesFromDb = reservesRepository.GetAll().ToList(); transaction.Commit(); } } // Assert Assert.IsTrue(reservesFromDb.Count == 1, "No Reserves from database."); //Assert.IsTrue(reservesFromDb[0].ReserveBills.Count == 1); }
public void Can_Save_AdminJobsVoting_To_DB() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime"); BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; AdministrationJobsVoting administrationJobsVoting = new AdministrationJobsVoting( AdministrationJobsType.Regular, building, "Subject", "Description", new DateTime(2011, 11, 11)); AdminJobsVotingsNHRepository adminJobsVotingsNhRepository = new AdminJobsVotingsNHRepository(SessionFactory); // Act AdministrationJobsVoting adminJobsVotingFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); session.Save(building); adminJobsVotingsNhRepository.SaveOrUpdate(administrationJobsVoting); tx.Commit(); } using (var tx = session.BeginTransaction()) { adminJobsVotingFromDb = adminJobsVotingsNhRepository.GetById(administrationJobsVoting.Id); tx.Commit(); } } // Assert Assert.AreEqual(administrationJobsVoting, adminJobsVotingFromDb, "Two administration jobs voting entities aren't equal."); }
public void SetUp() { cadastre = new Cadastre("Trešnjevka", "332134", new City(10000, "Zagreb")); cadastralParticle = new CadastralParticle(cadastre, "123", 120, "opis"); landRegistry = new LandRegistry(cadastralParticle); var buildingManager = new BuildingManager(new LegalPerson("12345678903", "Upravitelj")); building = new Building(buildingManager) { LandRegistry = landRegistry }; partitionSpace1 = landRegistry.CreatePartitionSpace("123", 23, "Stan 1", new PhysicalPerson("12345678903", "Mile1", "Milic")); partitionSpace2 = landRegistry.CreatePartitionSpace("123", 23, "Stan 2", new PhysicalPerson("12345678904", "Mile2", "Milic")); partitionSpace3 = landRegistry.CreatePartitionSpace("123", 23, "Stan 3", new PhysicalPerson("12345678905", "Mile3", "Milic")); partitionSpace4 = landRegistry.CreatePartitionSpace("123", 23, "Stan 4", new PhysicalPerson("12345678906", "Mile4", "Milic")); }
public void Can_Save_Building_To_DB() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime"); BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; BuildingsNHRepository buildingsNhRepository = new BuildingsNHRepository(SessionFactory); // Act Building buildingFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); buildingsNhRepository.SaveOrUpdate(building); tx.Commit(); } using (var tx = session.BeginTransaction()) { buildingFromDb = buildingsNhRepository.GetById(building.Id); tx.Commit(); } } // Assert Assert.AreEqual(building, buildingFromDb, "Two building entities aren't equal."); }
public void SetUp() { cadastre = new Cadastre("Trešnjevka", "332134", new City(10000, "Zagreb")); cadastralParticle = new CadastralParticle(cadastre, "123", 120, "opis"); landRegistry = new LandRegistry(cadastralParticle); }
public void SetUp() { cadastre = new Cadastre("Trešnjevka", "332134", new City(10000, "Zagreb")); }