public void CanParse(string xmlContent, bool expectedResult) { // arrange var doc = XDocument.Parse(xmlContent); var parser = new InspectCodeParser(); // act var result = parser.CanParse(doc); // assert Assert.Equal(expectedResult, result); }
public void CanParse_LoadingException() { // arrange var parser = new InspectCodeParser(); parser.FileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { "wrongreport.xml", new MockFileData("<Report ToolsVersion=\"8.2\"></Rport>") }, }); // act var exception = Assert.Throws <Exceptions.LoadingReportException>(() => parser.CanParse("wrongreport.xml")); // assert Assert.Equal(3, exception.ExitCode); Assert.Equal("An exception happened when loading the report 'wrongreport.xml'", exception.Message); Assert.NotNull(exception.InnerException); }
public void CanParse(string reportPath, bool expectedResult) { // arrange var parser = new InspectCodeParser(); parser.FileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { "inspectcodereport.xml", new MockFileData(TestUtilities.GetEmbeddedResourceContent("inspectcodereport.xml")) }, { "inspectcodereport_2016.2.xml", new MockFileData(TestUtilities.GetEmbeddedResourceContent("inspectcodereport_2016.2.xml")) }, { "emptyreport.xml", new MockFileData("<Report ToolsVersion=\"8.2\"></Report>") }, { "onlyissues.xml", new MockFileData("<IssueTypes></IssueTypes>") }, { "falsereport.xml", new MockFileData("{<IssueTypes></IssueTypes>") }, }); // act var result = parser.CanParse(reportPath); // assert Assert.Equal(expectedResult, result); }