public void Can_Add_Multiple_Telephone_Numbers()
        {
            // Arrange
            PhysicalPerson person = new PhysicalPerson("12345678901", "Mile", "Milic");
            Telephone telephone1 = new Telephone("Kucni telefon", "123456");
            Telephone telephone2 = new Telephone("Mobitel", "098123456");

            // Act
            person.AddTelephone(telephone1);
            person.AddTelephone(telephone2);

            // Assert
            Assert.AreEqual(2, person.Telephones.Count, "Trebala bi postojati dva telefonska broja.");
            Assert.AreEqual("123456", person.Telephones.ElementAt(0).TelephoneNumber, "Prvi broj telefona nije isti kao zadani.");
            Assert.AreEqual("098123456", person.Telephones.ElementAt(1).TelephoneNumber, "Drugi broj telefona nije isti kao zadani.");
        }
        public void Can_Take_Snapshot_Of_Person()
        {
            // Arrange
            PhysicalPerson person = new PhysicalPerson("12345678901", "Mile", "Milic");
            Telephone telephone1 = new Telephone("Kucni telefon", "123456");
            Telephone telephone2 = new Telephone("Mobitel", "098123456");

            person.AddTelephone(telephone1);
            person.AddTelephone(telephone2);

            // Act
            var personSnapshot = new PersonSnapshot(person);

            // Assert
            Assert.AreEqual(person.Oib, personSnapshot.Oib);
            Assert.AreEqual(person.FullName, personSnapshot.FullName);
            Assert.AreEqual(person.Address, personSnapshot.Address);
        }
        public void Can_Remove_Existing_Telehone_Number()
        {
            // Arange
            PhysicalPerson person = new PhysicalPerson("12345678901", "Mile", "Milic");
            Telephone telephone1 = new Telephone("Kucni telefon", "123456");
            Telephone telephone2 = new Telephone("Mobitel", "098123456");

            person.AddTelephone(telephone1);
            person.AddTelephone(telephone2);

            // Act
            var isSuccess = person.RemoveTelephone(telephone1);

            // Assert
            Assert.IsTrue(isSuccess);
            Assert.AreEqual(1, person.Telephones.Count, "Trebao bi postojati jedan telefonski broj.");
            Assert.AreEqual("098123456", person.Telephones.ElementAt(0).TelephoneNumber, "To nije broj mobitela, odnosno drugi zadani broj telefona..");
        }
        public void Can_Save_Person_With_Telephone_To_DB()
        {
            // Arrange
            Person person = new PhysicalPerson("12345678901", "Ivo", "Ivic");
            person.AddTelephone(new Telephone("Posao", "098 888 999"));

            PersonsNHRepository personsNhRepository = new PersonsNHRepository(SessionFactory);

            // Act
            using (var session = SessionFactory.OpenSession()) {
                using (var tx = session.BeginTransaction()) {
                    personsNhRepository.SaveOrUpdate(person);
                    tx.Commit();
                }

            }

            IList<Person> persons = null;
            using (var session = SessionFactory.OpenSession()) {
                using (var tx = session.BeginTransaction()) {
                    persons = personsNhRepository.GetAll().ToList();
                    tx.Commit();
                }

            }

            // Assert
            Assert.IsTrue(persons.Contains(person), "PhysicalPerson doesn't exists in database.");
            Assert.IsTrue(person.Telephones.Contains(persons[0].Telephones.ElementAt(0)));
        }