public void ListSourceAdd() { tlog.Debug(tag, $"ListSourceAdd START"); var para = new TestEnumerable(); var testingTarget = new ListSource(para); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <ListSource>(testingTarget, "should be an instance of testing target class!"); var ret = testingTarget.Add(4); Assert.AreEqual(ret, 3, "The index of ListSouce should is 3."); Assert.AreEqual(testingTarget.Count, 4, "The count of ListSouce should be 4."); testingTarget.Dispose(); tlog.Debug(tag, $"ListSourceAdd END (OK)"); }
/// <summary> /// Permet d'ajouter un enregistrement à la grille de données. /// Dans un premier temps, la grille est vérouillé tant que l'utilisateur ne valide pas la saisie de ce nouvel enregistrement. /// </summary> /// <param name="obj"></param> private void FonctionAddDelegate(object obj) { if (IsLoading == Visibility.Visible) { ShowMessageBox.Show(TYPE_WINDOW_BOX.AVERTISSEMENT, messLoading, ""); } else { bool flag = true; if (this.Mode == MODE_COMPOSANT_REFERENTIIEL.CONSULT) { IDTO dto = BLL.CreateElement(); // L'observer est appelé pour mettre à jour les champs que le développeur souhaite // Ex : Champs de traca (Date heure creation, modif, ...) if (Client != null) { Client.AfterCreate(ref dto); } ListSource.Add(dto); CurrentElement = dto; } else { if (this.Mode == MODE_COMPOSANT_REFERENTIIEL.ADD) { foreach (ChampGenerique current in this.ControlChamps.CollectionChamps) { if (!current.IsValid) { flag = false; break; } } if (!flag) { ShowMessageBox.Show(TYPE_WINDOW_BOX.AVERTISSEMENT, "", "La validation a échoué. Certains champs sont invalides par rapport aux contraintes définies dans la configuration."); } } } this.Mode = (flag ? ((this.Mode == MODE_COMPOSANT_REFERENTIIEL.CONSULT) ? MODE_COMPOSANT_REFERENTIIEL.ADD : MODE_COMPOSANT_REFERENTIIEL.CONSULT) : this.Mode); } }