Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            FileReader re = new FileReader(@"C:\Users\PrimoTibalt\Desktop\Studying\NET.W.2019.Shchahlou\NET.W.2019.Shchahlou.17\text.txt");

            string[] text = re.ReadAll();
            Console.WriteLine("URLs for test: ");
            StringBuilder bldr = new StringBuilder();

            foreach (string str in text)
            {
                Console.WriteLine(str);
                bldr.AppendLine(str);
            }

            Validator   val       = new Validator();
            StringToXml converter = new StringToXml();
            XMLWriter   writer    = new XMLWriter(val, converter, "default.xml");

            writer.Write(bldr.ToString());
            Console.WriteLine("The final XML File : ");
            string xml;

            using (StreamReader reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "default.xml"))
            {
                xml = reader.ReadToEnd();
            }
            Console.WriteLine(xml);
        }
Exemplo n.º 2
0
        public void Gst_NetCost()
        {
            var value          = @"Hi Yvaine,
                        Please create an expense claim for the below. Relevant details are marked up as
                        requested…
                        <expense><total>1024.01</total>
                        <payment_method>personal card</payment_method>
                        </expense>
                        From: Ivan Castle
                        Sent: Friday, 16 February 2018 10:32 AM
                        To: Antoine Lloyd <*****@*****.**>
                        Subject: test
                        Hi Antoine,
                        Please create a reservation at the <vendor>Viaduct Steakhouse</vendor> our
                        <description>development team’s project end celebration dinner</description> on
                        <date>Tuesday 27 April 2017</date>. We expect to arrive around
                        7.15pm. Approximately 12 people but I’ll confirm exact numbers closer to the day.
                        Regards,
                        Ivan";
            var emailViewModel = new EmailViewModel(new EmailRepository());
            var xDocument      = emailViewModel.ProcessingData(StringToXml.ToXml(value));
            var xGst           = xDocument.Descendants().SingleOrDefault(p => p.Name.LocalName == GlobalConstant.GST);
            var xNet_Total     = xDocument.Descendants().SingleOrDefault(p => p.Name.LocalName == GlobalConstant.NET_TOTAL);

            Assert.AreEqual(xGst.Value, "133.57");
            Assert.AreEqual(xNet_Total.Value, "890.44");
        }
Exemplo n.º 3
0
        public IHttpActionResult Create(string value)
        {
            try
            {
                var xml  = StringToXml.ToXml(value);
                var root = GetResult(xml);

                _emailRepository.Create(new EmailRecord {
                    Data = xml
                });
                return(new CustomResponse(HttpStatusCode.OK, root.root));
            }
            catch (Exception ex)
            {
                return(new CustomResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
Exemplo n.º 4
0
        public void InvalidXml()
        {
            var value = @"Hi Yvaine,
                        Please create an expense claim for the below. Relevant details are marked up as
                        requested…
                        <expense><total>1024.01</total><cost_centre>DEV002</cost_centre>
                        <payment_method>personal card
                        </expense>
                        From: Ivan Castle
                        Sent: Friday, 16 February 2018 10:32 AM
                        To: Antoine Lloyd <*****@*****.**>
                        Subject: test
                        Hi Antoine,
                        Please create a reservation at the <vendor>Viaduct Steakhouse</vendor> our
                        <description>development team’s project end celebration dinner</description> on
                        <date>Tuesday 27 April 2017</date>. We expect to arrive around
                        7.15pm. Approximately 12 people but I’ll confirm exact numbers closer to the day.
                        Regards,
                        Ivan";

            StringToXml.ToXml(value);
        }