예제 #1
0
        public void Telephone_Must_Be_A_Value_Object()
        {
            // Arrange
            Telephone telephone = new Telephone("Kucni", "123");

            // Act

            // Assert
            Assert.IsInstanceOf(typeof(ValueObject), telephone);
        }
예제 #2
0
        public void Two_Telehones_Should_Be_Equal()
        {
            // Arrange
            Telephone telephone1 = new Telephone("Kucni", "123");
            Telephone telephone2 = new Telephone("Kucni", "123");

            // Act
            var areEqual = telephone1.Equals(telephone2);

            // Assert
            Assert.IsTrue(areEqual);
        }
        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
            LegalPerson person = new LegalPerson("12345678901", "Mile");
            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.Name, 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..");
        }
예제 #6
0
 /// <summary>
 /// Brise telefonski broj
 /// </summary>
 /// <param name="telephone">telefonski broj</param>
 /// <returns>True ako je brisanje uspjelo, inace false</returns>
 public virtual bool RemoveTelephone(Telephone telephone)
 {
     return telephones.Remove(telephone);
 }
예제 #7
0
 /// <summary>
 /// Dodaje novi broj telefona osobi.
 /// Ukoliko već postoji telefosnki broj s istim imenom, postojeći 
 /// se zamjenjuje novim.
 /// </summary>
 /// <param name="telephone">broj telefona</param>
 public virtual void AddTelephone(Telephone telephone)
 {
     var isSucceded = telephones.Add(telephone);
     if(!isSucceded) {
         var existingTelephone =
             telephones.Where(t => t.NameOfTelephoneNumber == telephone.NameOfTelephoneNumber).SingleOrDefault();
         RemoveTelephone(existingTelephone);
         telephones.Add(telephone);
     }
 }