public void TestCopyOverwrite() { TemplatesService ts = new TemplatesService(storage); ts.Start(); ITeamTemplatesProvider teamtemplateprovider = ts.TeamTemplateProvider; LMTeam teamB = LMTeam.DefaultTemplate(5); teamB.Name = "B"; teamB.TeamName = "Template B"; teamB.FormationStr = "1-4"; teamB.List [0].Name = "Paco"; teamtemplateprovider.Save(teamB); LMTeam teamA = new LMTeam(); teamA.Name = "A"; teamA.TeamName = "Template A"; teamA.FormationStr = "1-4-3-3"; teamtemplateprovider.Save(teamA); LMTeam auxdelete = teamA; teamtemplateprovider.Copy(teamB, "A"); teamtemplateprovider.Delete(auxdelete); teamA = teamtemplateprovider.Templates [0] as LMTeam; Assert.AreEqual(4, teamtemplateprovider.Templates.Count); Assert.AreEqual("A", teamA.Name); Assert.AreEqual("Template B", teamA.TeamName); Assert.AreEqual(teamB.List.Count, teamA.List.Count); Assert.AreEqual("1-4", teamA.FormationStr); Assert.AreEqual("Paco", teamA.List [0].Name); }
void HandleEdited(object o, EditedArgs args) { TreeIter iter; teams.GetIter(out iter, new TreePath(args.Path)); string name = (string)teams.GetValue(iter, 2); if (name != args.NewText) { if (templatesNames.Contains(args.NewText)) { Config.GUIToolkit.ErrorMessage( Catalog.GetString("A team with the same name already exists"), this); args.RetVal = false; } else { try { Team team = provider.Load(name); team.Name = args.NewText; provider.Save(team); provider.Delete(name); templatesNames.Remove(name); templatesNames.Add(team.Name); teams.SetValue(iter, 1, args.NewText); teams.SetValue(iter, 2, args.NewText); } catch (Exception ex) { Config.GUIToolkit.ErrorMessage(ex.Message); } } } }