/// <summary>
 /// Metoda gumba za dodajanje novih oseb.
 /// </summary>
 private void AddPersonButtonClick(object sender, RoutedEventArgs e)
 {
     if (Mode == ManagerMode.DISPLAY)
     {
         SelectedPerson = new Person();
         Mode           = ManagerMode.CREATE;
     }
     else if (Mode == ManagerMode.CREATE)
     {
         personList.Add(SelectedPerson);
         SelectedPerson.ID = (int)Storage?.AddNew(SelectedPerson);
         Mode = ManagerMode.DISPLAY;
     }
 }
Beispiel #2
0
        public void Test_AddPerson()
        {
            ObservableCollection <Person> list = new ObservableCollection <Person>();
            Person john = new Person(0, "John", "Doe", "10001", new Address());

            list.Add(john);
            DataStorage storage = new DataStorage("./test_ds_save_load.xml");

            storage.SaveData(list);

            storage.AddNew(new Person(-1, "Jane", "Doe", "10002", new Address()));
            ObservableCollection <Person> loadedList = storage.LoadData();

            Assert.AreEqual(list.Count + 1, loadedList.Count);
        }