Example #1
0
        public void TaxItemTest(string inputFile, string outputFile, Models.EbIVersion ebIVersion)
        {
            var invoice = InvoiceFactory.LoadTemplate(inputFile);

            invoice.PrintDump();
            EbInterfaceResult result = invoice.Save(outputFile, ebIVersion);

            Assert.That(result.ResultType == ResultType.IsValid);
            var inputXml = XDocument.Load(inputFile);
            var savedXml = XDocument.Load(outputFile);
            var inResult = inputXml.Descendants()
                           .Where(p1 => p1.Descendants().Count() == 0)
                           .Select(p => new NodeList
            {
                NodePath = p.GetPath(),
                Value    = p.Value
            }).Distinct().OrderBy(n => n.NodePath).ToList();
            var outResult = savedXml.Descendants().Where(p1 => p1.Descendants().Count() == 0).Select(p => new NodeList
            {
                NodePath = p.GetPath(),
                Value    = p.Value
            }).Distinct().OrderBy(n => n.NodePath).ToList();

            Console.WriteLine("Nodes not in Output -----------------------");
            var notInOut = inResult.Where(p => !outResult.Any(p2 => p2.NodePath == p.NodePath)).ToList();

            PrintDiff(notInOut);
            Console.WriteLine("Nodes not in Input -----------------------");

            var notInIn = outResult.Where(p => !inResult.Any(p2 => p2.NodePath == p.NodePath)).ToList();

            PrintDiff(notInIn);
            Console.WriteLine("Value different -----------------------");
            var valDif = inResult.Where(p => outResult.Any(p2 => p2.NodePath == p.NodePath && p2.Value != p.Value));
        }
Example #2
0
        public void SaveInvoiceTest(string inputFile, string outputFile, Models.EbIVersion ebIVersion, string expectedAttr)
        {
            var invoice = InvoiceFactory.LoadTemplate(inputFile);
            //invoice.PrintDump();
            EbInterfaceResult result = invoice.Save(outputFile, ebIVersion);

            result.PrintDump();
            Assert.That(result.ResultType == ResultType.IsValid, $"Validation Error: {outputFile} ");
            XDocument xInv  = XDocument.Load(outputFile);
            var       attrs = xInv.Root.Attributes().Where(p => p.IsNamespaceDeclaration == true).FirstOrDefault(x => x.Name.LocalName == "eb");

            Assert.IsNotNull(attrs);
            Assert.AreEqual(expectedAttr, attrs.Value);
        }