public void TestWriteToXmlAndReadFromXmlOnDispatcherSettings()
        {
            DependencyResolver.Reset();
            DependencyResolver.Initialize();
            
            var dispatcherSettings = DummyDispatcherSettings();

            var firstWrite = new XmlDocument();
            firstWrite.AppendChild(firstWrite.CreateElement("DispatcherSettings"));
            dispatcherSettings.WriteTo(firstWrite.DocumentElement);

            var anotherDispatcherSettings = new DispatcherSettings();
            anotherDispatcherSettings.ReadFrom(firstWrite.DocumentElement);

            var secondWrite = new XmlDocument();
            secondWrite.AppendChild(secondWrite.CreateElement("DispatcherSettings"));
            anotherDispatcherSettings.WriteTo(secondWrite.DocumentElement);

            var firstString = new StringBuilder();
            var firstText = XmlWriter.Create(firstString);
            firstWrite.Save(firstText);

            var secondString = new StringBuilder();
            var secondText = XmlWriter.Create(secondString);
            secondWrite.Save(secondText);

            secondString.ToString().Should().BeEquivalentTo(firstString.ToString());
        }
        public void ReadFrom(XmlElement bootstrapSettingsElement)
        {
            //LaunchTimeout
            if (bootstrapSettingsElement.HasAttribute("LaunchTimeout"))
            {
                int launchTimeout;
                LaunchTimeout = Int32.TryParse(bootstrapSettingsElement.GetAttribute("LaunchTimeout"), out launchTimeout)
                    ? TimeSpan.FromMilliseconds(launchTimeout)
                    : TimeSpan.FromSeconds(30);
            }

            //DispatcherSettings
            var dispatchersElements = bootstrapSettingsElement.GetElementsByTagName("Dispatchers")[0].ChildNodes;
            foreach (XmlElement dispatcherSettingsElement in dispatchersElements)
            {
                var dispatcherSettings = new DispatcherSettings();
                dispatcherSettings.ReadFrom(dispatcherSettingsElement);
                DispatcherSettings.Add(dispatcherSettings);
            }

            //BootstrapJobs
            var bootstrapSettingsElementsExists =
                bootstrapSettingsElement.GetElementsByTagName("BootstrapJobs").Count == 1 &&
                bootstrapSettingsElement.GetElementsByTagName("BootstrapJob").Count > 0;

            if (!bootstrapSettingsElementsExists) 
                return;
            var bootstrapJobsElements =
                bootstrapSettingsElement.GetElementsByTagName("BootstrapJobs")[0].ChildNodes;
            foreach (XmlElement bootstrapJobElement in bootstrapJobsElements)
            {
                var bootstrapJob = new BootstrapJob();
                bootstrapJob.ReadFrom(bootstrapJobElement);
                BootstrapJobs.Add(bootstrapJob);
            }
        }