public IHttpActionResult PostXMLInput([FromBody] XmlDocument xml) { XMLInput xmlInput = new XMLInput(); xmlInput.XML = xml.InnerXml; return(null); }
/// <summary> /// Helper method to call NXUnit assertions on the /// output from the test method and comparing the /// actual output to the expected output. /// This method uses the ignore rules to remove the nodes that cannot be compared /// from the actual and expected XML files before doing the assertions. /// </summary> /// <param name="pInfo"></param> /// <param name="methodName"></param> /// <param name="scenarioName"></param> private void AssertResult(ParameterInfo pInfo, string methodName, string scenarioName) { string outputFileName = GetFileName(pInfo, methodName, scenarioName); string actualOutputPath = Path.Combine(ActualOutputDir, outputFileName); string expectedOutputPath = Path.Combine(ExpectedOutputDir, outputFileName); string rulesPath = Path.Combine(RulesDir, outputFileName); XmlDocument rules = new XmlDocument(); try { if (File.Exists(rulesPath)) { rules.Load(rulesPath); } } catch (Exception e) { string errorMessage = string.Format("Could not load the assertion rules from the file {0} for the test method {1} and scenario {2}.", rulesPath, methodName, scenarioName); throw new AsserterException(errorMessage, e); } XmlDocument actualXml = new XmlDocument(); try { actualXml.Load(actualOutputPath); ApplyRules(actualXml, rules); } catch (Exception e) { string errorMessage = string.Format("Could not load the actual output from the file {0} for the test method {1} and scenario {2}.", actualOutputPath, methodName, scenarioName); throw new AsserterException(errorMessage, e); } XmlDocument expectedXml = new XmlDocument(); try { expectedXml.Load(expectedOutputPath); ApplyRules(expectedXml, rules); } catch (Exception e) { string errorMessage = string.Format("Could not load the expected output from the file {0} for the test method {1} and scenario {2}.", expectedOutputPath, methodName, scenarioName); throw new AsserterException(errorMessage, e); } XMLInput actual = XMLInput.CreateInput(actualXml); XMLInput expected = XMLInput.CreateInput(expectedXml); AssertStrategy strategy = XMLAssert.DEFAULT_STRATEGY; strategy.IsEmptyAttrSensitive = false; strategy.IsEmptyElementSensitive = false; strategy.IsWhitespaceSensitive = false; strategy.IsOrderSensitive = false; XMLAssert xa = XMLAssert.CreateInstance(strategy); CompareResult cr = xa.Compare(expected, actual); foreach (Diff dif in cr) { Console.WriteLine(dif.ToString()); } xa.AreEqual(expected, actual, "not equal", new object[] { null }); }