public void ToStringTest()
 {
     string n = "Sarah Connor"; // TODO: initialisez à une valeur appropriée
     Astronaut target = new Astronaut(n); // TODO: initialisez à une valeur appropriée
     string expected = "Sarah Connor is available"; // TODO: initialisez à une valeur appropriée
     string actual;
     actual = target.ToString();
     Assert.AreEqual(expected, actual);
 }
        /// <summary>
        /// Va lire le fichier Xml lancé par l'utilisateur pour une nouvelle mission
        /// </summary>
        /// <returns>Un booléen indiquant si le chargement c'est bien passé</returns>
        private bool NewMission()
        {
            this.Astronauts.Clear();
            this.Categories.Clear();
            this.AstronautList.Items.Clear();
            saveToolStripMenuItem.Enabled = true;
            XmlDocument file = new XmlDocument();
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter = "Text Files (.xml)|*.xml|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.Multiselect = false;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {

                    this.StartMission = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                    file.Load(openFileDialog1.OpenFile());
                    XmlNode noeud = file.DocumentElement;
                    XmlNodeList nomMission = noeud.SelectNodes("Name");
                    this.Text = nomMission[0].InnerText;

                    XmlNodeList MapMars = noeud.SelectNodes("Map");
                    this.Map = MapMars[0].InnerText;

                    try
                    {
                        Image.FromFile(this.Map);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to find Map picture : " + this.Map);
                        return false;
                    }

                    XmlNodeList XMap = noeud.SelectNodes("X");
                    this.xOrigin = int.Parse(XMap[0].InnerText);

                    XmlNodeList YMap = noeud.SelectNodes("Y");
                    this.yOrigin = int.Parse(YMap[0].InnerText);

                    XmlNode AstronautXml = noeud.SelectSingleNode("Astronauts");
                    XmlNodeList AstronautsXml = AstronautXml.SelectNodes("Astronaut");

                    foreach (XmlNode nodeAstro in AstronautsXml)
                    {
                        Astronaut A = new Astronaut(nodeAstro.InnerText);
                        Astronauts.Add(A);
                    }

                    XmlNode ActivityXml = noeud.SelectSingleNode("Activities");
                    XmlNodeList ActivitiesXml = ActivityXml.ChildNodes;

                    foreach (XmlNode category in ActivitiesXml)
                    {
                        Category c = new Category(category.LocalName);
                        Categories.Add(c);
                        XmlNodeList Activities = category.ChildNodes;

                        foreach (XmlNode activity in Activities)
                        {
                            if (activity.LocalName == "Activity")
                            {
                                Activity a = new Activity(activity.InnerText);
                                c.addActivity(a);
                            }
                            else
                            {
                                Category c2 = new Category(activity.Name);
                                c.addActivity(c2);
                                XmlNodeList SecondaryActivity = activity.ChildNodes;

                                foreach (XmlNode SubActivity in SecondaryActivity)
                                {
                                    Activity a2 = new Activity(SubActivity.InnerText);
                                    c2.addActivity(a2);
                                }
                            }
                        }
                    }

                    return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                    return false;
                }
            }
            else
                return false;
        }
        /// <summary>
        /// Va lire un fichier Xml décrivant la mission (Activité, Map...)
        /// </summary>
        /// <param name="Path">Le chemin vers un fichier Xml</param>
        /// <returns>Un booléen indiquant si le chargement c'est bien passé</returns>
        private bool LoadMissionXml(string Path)
        {
            XmlDocument file = new XmlDocument();

                try
                {
                    file.Load(Path);
                    XmlNode noeud = file.DocumentElement;
                    XmlNodeList nomMission = noeud.SelectNodes("Name");
                    this.Text = nomMission[0].InnerText;

                    XmlNodeList MapMars = noeud.SelectNodes("Map");
                    this.Map = MapMars[0].InnerText;

                    try
                    {
                        Image.FromFile(this.Map);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to find Map picture : " + this.Map);
                        return false;
                    }

                XmlNodeList XMap = noeud.SelectNodes("X");
                    this.xOrigin = int.Parse(XMap[0].InnerText);

                    XmlNodeList YMap = noeud.SelectNodes("Y");
                    this.yOrigin = int.Parse(YMap[0].InnerText);

                    XmlNode AstronautXml = noeud.SelectSingleNode("Astronauts");
                    XmlNodeList AstronautsXml = AstronautXml.SelectNodes("Astronaut");

                    foreach (XmlNode nodeAstro in AstronautsXml)
                    {
                        Astronaut A = new Astronaut(nodeAstro.InnerText);
                        Astronauts.Add(A);
                    }

                    XmlNode ActivityXml = noeud.SelectSingleNode("Activities");
                    XmlNodeList ActivitiesXml = ActivityXml.ChildNodes;

                    foreach (XmlNode category in ActivitiesXml)
                    {
                        Category c = new Category(category.LocalName);
                        Categories.Add(c);
                        XmlNodeList Activities = category.ChildNodes;

                        foreach (XmlNode activity in Activities)
                        {
                            if (activity.LocalName == "Activity")
                            {
                                Activity a = new Activity(activity.InnerText);
                                c.addActivity(a);
                            }
                            else
                            {
                                Category c2 = new Category(activity.Name);
                                c.addActivity(c2);
                                XmlNodeList SecondaryActivity = activity.ChildNodes;

                                foreach (XmlNode SubActivity in SecondaryActivity)
                                {
                                    Activity a2 = new Activity(SubActivity.InnerText);
                                    c2.addActivity(a2);
                                }
                            }
                        }
                    }
                    return true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                    return false;
                }
        }
        /// <summary>
        /// Va vérifier qu'un Astonaute est disponible
        /// </summary>
        /// <param name="A">astronaute dont on veut connaître la disponibilité</param>
        /// <returns></returns>
        private bool AstronautIsFree(Astronaut A)
        {
            List<Task> AstroTask;
            AstroTask = ActualDay.Tasks.FindAll(x => x.Astronauts.Contains(A));
            int EndNewTask = MinuteStartSend + MinuteDurationSend;
            int EndTask;
            bool AstronautFree = true;

            foreach (Task task in AstroTask)
            {
                EndTask = task.DurationMinute + task.StartHour;
                if((MinuteStartSend > task.StartHour && MinuteStartSend < EndTask) || (EndNewTask > task.StartHour && EndNewTask < EndTask))
                {
                    AstronautFree = false;
                }
            }

            return AstronautFree;
        }
 /// <summary>
 /// Fonction qui va supprimer un Astronaute de la tâche
 /// </summary>
 /// <param name="astronaut">Astronaute à supprimmer</param>
 public void RemoveAstronaut(Astronaut astronaut)
 {
     try
     {
         Astronauts.Remove(astronaut);
         astronaut.Available = true;
     }
     catch
     { Console.WriteLine("{0} is not assigned to this task", astronaut.Name); }
 }
 /// <summary>
 /// Fonction qui va ajouter un astronaute à la tâche
 /// </summary>
 /// <param name="astronaut">Astronaute à ajouter</param>
 public void AddAstronaut(Astronaut astronaut)
 {
     if (astronaut.Available == true)
     {
         Astronauts.Add(astronaut);
         astronaut.Available = false;
     }
     else
     {
         Console.WriteLine("This astronaut is not available");
     }
 }