示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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"]));
        }
示例#4
0
        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);
        }
示例#5
0
        public void XmlNodeReturnedHasStatus()
        {
            var alertElement = XmlCreator.Create(Alert);

            var statusElement = alertElement.Element(XmlCreator.Cap12Namespace + "status");

            Assert.NotNull(statusElement);
            Assert.Equal("Test", statusElement.Value);
        }
示例#6
0
        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));
        }
示例#8
0
        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());
        }
示例#9
0
        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());
        }
示例#10
0
        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());
        }
示例#11
0
        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());
        }
示例#12
0
        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());
        }
示例#13
0
        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());
        }
示例#14
0
        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());
        }
示例#15
0
        public void XmlNodeReturnedHasCAP12Namespace()
        {
            XElement xmlElement = XmlCreator.Create(Alert);

            Assert.Equal("urn:oasis:names:tc:emergency:cap:1.2", xmlElement.Name.NamespaceName);
        }