Exemple #1
0
        public static Diff DiffNodeSetFiles(string controlFileName, string testFileName)
        {
            var controlInfo = LoadNamespaces(controlFileName);
            var testInfo    = LoadNamespaces(testFileName);

            var controlNamespaces = controlInfo.Item1;
            var controlAliases    = controlInfo.Item2;

            var testNamespaces = testInfo.Item1;
            var testAliases    = testInfo.Item2;

            var controlFile = File.ReadAllText(controlFileName);
            var testFile    = File.ReadAllText(testFileName);

            controlFile = NormalizeAliasesAndNamespaces(controlFile, controlAliases, controlNamespaces);
            testFile    = NormalizeAliasesAndNamespaces(testFile, testAliases, testNamespaces);

            var diffHelper = new OpcNodeSetXmlUnit(controlAliases, controlNamespaces, testAliases, testNamespaces, controlFile, testFile);

            Diff d = DiffBuilder
                     .Compare(Input.FromString(controlFile))
                     .WithTest(Input.FromString(testFile))
                     .CheckForSimilar()
                     .WithDifferenceEvaluator(diffHelper.OpcNodeSetDifferenceEvaluator)
                     .WithNodeMatcher(new DefaultNodeMatcher(new ElementSelector[] { diffHelper.OpcElementSelector }))
                     .Build();

            return(d);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var compareFileName
                = @"..\..\..\..\..\TestNodeSets\opcfoundation.org.UA.Robotics.NodeSet2.xml";
            //= @"..\..\..\..\..\TestNodeSets\Clabs.UA.HumanRobot.NodeSet2.xml";
            var testFileName
                = @"..\..\..\..\..\TestNodeSets\opcfoundation.org.UA.Robotics.Nodeset2.Exported.xml";
            //= @"..\..\..\..\..\TestNodeSets\clabs.com.UA.HumanRobot.Nodeset2.Exported.xml";

            Diff d = OpcNodeSetXmlUnit.DiffNodeSetFiles(compareFileName, testFileName);

            string diffControl, diffTest, diffSummary;

            OpcNodeSetXmlUnit.GenerateDiffSummary(d, out diffControl, out diffTest, out diffSummary);

            File.WriteAllText("summarydiff.xml", diffSummary);
            File.WriteAllText("controldiff.xml", diffControl);
            File.WriteAllText("testdiff.xml", diffTest);
        }