public static void SerializeToXML(ArcGISHealthChecker arcGISHealtChecker, string fileName) { XmlSerializer serializer = new XmlSerializer(typeof(ArcGISHealthChecker)); TextWriter textWriter = new StreamWriter(fileName); serializer.Serialize(textWriter, arcGISHealtChecker); textWriter.Close(); }
public void ShouldSerializeProperly() { HTTPService restService = new HTTPService { Type = "TestService", Name = "TestService", Url = "testeurl.com" }; TCPService tcpService = new TCPService { Type = "TestService", Name = "TestService", Host = "testeurl.com", Port = "5555" }; var arcGISHealtChekerGroup = new ArcGISHealthCheckerGroup { Name = "TestProject", HTTPServices = new List<HTTPService> { restService }, TCPServices = new List<TCPService> { tcpService } }; var arcGISHealtCheker = new ArcGISHealthChecker { Groups = new List<ArcGISHealthCheckerGroup> { arcGISHealtChekerGroup } }; var testFile = GetTempTestFileName(); ConfigurationReader.SerializeToXML(arcGISHealtCheker, testFile); File.Exists(testFile).Should().Be.True(); File.Delete(testFile); }