public void MultipleAlertXmlIsSerializedCorrectly() { var orangeAlertElement = XmlCreator.Create(CreateMultipleAlertXmlAlert()); var document = new XDocument(orangeAlertElement); string alertAsString; var writerSettings = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8, NewLineChars = "\n" }; using (var memoryStream = new MemoryStream()) { var streamWriter = new StreamWriter(memoryStream, Encoding.UTF8); using (var writer = XmlWriter.Create(streamWriter, writerSettings)) { document.Save(writer); } memoryStream.Seek(0, SeekOrigin.Begin); alertAsString = new StreamReader(memoryStream, Encoding.UTF8).ReadToEnd(); } var expectedResult = Xml.MultipleAlertXml.Replace("\r\n", "\n"); Assert.Equal(expectedResult, alertAsString); }
static void Main(string[] args) { var boy = new Person { Id = "A123", Name = "a", PhoneNumber = 123, PlaceOfBirth = "Bangalore", DateAndTimeOfBirth = DateTime.Now, Gender = Gender.Male, SessionId = "bjf" }; var girl = new Person { Id = "B456", Name = "b", PhoneNumber = 456, PlaceOfBirth = "Bangalore", DateAndTimeOfBirth = DateTime.Now, Gender = Gender.Female, SessionId = "ckvj" }; var xmlRequestBody = XmlCreator.Create(boy, girl); var matchResponse = MatchMakerClient.GetMatch(xmlRequestBody); var compatibilityReportPath = XmlParser.ExtractCompatibilityReportPath(matchResponse); Console.WriteLine(compatibilityReportPath); }
static void Main(string[] args) { IKernel kernel = new StandardKernel(new ConfigModule()); IDataRetriever source = kernel.Get <IDataRetriever>(); XmlCreator.Create(source.LoadData(), Path.Combine(Directory.GetCurrentDirectory(), ConfigurationManager.AppSettings["targetFilePath"])); }
public void XmlNodeReturnedHasSentTime() { var alertElement = XmlCreator.Create(Alert); var sentElement = alertElement.Element(XmlCreator.Cap12Namespace + "sent"); Assert.NotNull(sentElement); Assert.Equal("2014-06-10T10:35:23-03:00", sentElement.Value); }
public void XmlNodeReturnedHasStatus() { var alertElement = XmlCreator.Create(Alert); var statusElement = alertElement.Element(XmlCreator.Cap12Namespace + "status"); Assert.NotNull(statusElement); Assert.Equal("Test", statusElement.Value); }
public void XmlNodeReturnedHasSender() { var alertElement = XmlCreator.Create(Alert); var senderElement = alertElement.Element(XmlCreator.Cap12Namespace + "sender"); Assert.NotNull(senderElement); Assert.Equal(Sender, senderElement.Value); }
public IActionResult Create(string xml) { // Create document string documentPath = XmlCreator.Create(xml); // Read file using XmlReader XmlParser.ParseFile(documentPath); // Read file using XmlDocument XmlParser.ParseDocument(documentPath); return(Json("Document is now available on " + documentPath)); }
private void AllElementsFilledXmlParseAndCreate() { string xmlContent = Xml.AllElementsFilledAlert; XDocument originalDocument = XDocument.Parse(xmlContent); Alert alert = XmlParser.Parse(xmlContent).First(); XElement createdElement = XmlCreator.Create(alert); XDocument createdDocument = new XDocument(); createdDocument.Add(createdElement); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
private void ThunderStorm12AllDatesXmlParseAndCreate() { string xmlContent = Xml.Thunderstorm12AllDatesXml; XDocument originalDocument = XDocument.Parse(xmlContent); Alert alert = XmlParser.Parse(xmlContent).First(); XElement createdElement = XmlCreator.Create(alert); XDocument createdDocument = new XDocument(); createdDocument.Add(createdElement); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
private void MultipleCircleXmlParseAndCreate() { string xmlContent = Xml.MultipleCircleXml; XDocument originalDocument = XDocument.Parse(xmlContent); Alert alert = XmlParser.Parse(xmlContent).First(); XElement createdElement = XmlCreator.Create(alert); XDocument createdDocument = new XDocument(); createdDocument.Add(createdElement); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
public void OrangeAlertXmlParseAndCreate() { string xmlContent = Xml.OrangeAlertXml; XDocument originalDocument = XDocument.Parse(xmlContent); Alert alert = XmlParser.Parse(xmlContent).First(); XElement createdElement = XmlCreator.Create(alert); XDocument createdDocument = new XDocument(); createdDocument.Add(createdElement); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
private void SevereThunderStormCap11ParseAndCreate() { string xmlContent = Xml.SevereThundertromCap11; string xmlContentToCap12 = xmlContent.Replace(XmlCreator.Cap11Namespace.ToString(), XmlCreator.Cap12Namespace.ToString()); XDocument originalDocument = XDocument.Parse(xmlContentToCap12); Alert alert = XmlParser.Parse(xmlContent).First(); XElement createdElement = XmlCreator.Create(alert); XDocument createdDocument = new XDocument(); createdDocument.Add(createdElement); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
private void MultipleParameterXmlParseAndCreate() { string xmlContent = Xml.MultipleParameterTestXml; string correctedXmlContent = xmlContent.Replace("Very Likely", "Likely"); XDocument originalDocument = XDocument.Parse(correctedXmlContent); Alert alert = XmlParser.Parse(xmlContent).First(); XElement createdElement = XmlCreator.Create(alert); XDocument createdDocument = new XDocument(); createdDocument.Add(createdElement); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
public void MultipleInfoAndAlertParseAndCreate() { string xmlContent = Xml.MultipleAlertAndInfoThunderstorm; string xmlContentToCap12 = xmlContent.Replace(XmlCreator.Cap11Namespace.ToString(), XmlCreator.Cap12Namespace.ToString()); XDocument originalDocument = XDocument.Parse(xmlContentToCap12); IEnumerable <Alert> alerts = XmlParser.Parse(xmlContent); IEnumerable <XElement> createdElements = XmlCreator.Create(alerts); XDocument createdDocument = new XDocument(); createdDocument.Add(new XElement(originalDocument.Root.Name, createdElements)); Assert.Equal(createdDocument.ToString(), originalDocument.ToString()); }
public void XmlNodeReturnedHasCAP12Namespace() { XElement xmlElement = XmlCreator.Create(Alert); Assert.Equal("urn:oasis:names:tc:emergency:cap:1.2", xmlElement.Name.NamespaceName); }