private static ITestResultsParserFactory CreateTestResultsParserFactory(UnitTestResultXmlFormat unitTestResultXmlFormat, ITestResultsParser testResultsParser)
        {
            ITestResultsParserFactory testResultsParserFactory = Substitute.For <ITestResultsParserFactory>();

            testResultsParserFactory.CreateParser(unitTestResultXmlFormat).Returns(testResultsParser);
            return(testResultsParserFactory);
        }
        public void ParseXml()
        {
            // Arrange
            string  xmlPath         = "/test/testresult.xml";
            TestRun expectedTestRun = new TestRun();
            UnitTestResultXmlFormat unitTestResultXmlFormat = UnitTestResultXmlFormat.NUnit;

            ITestResultsParser        testResultsParser        = CreateTestResultsParser(xmlPath, expectedTestRun);
            ITestResultsParserFactory testResultsParserFactory = CreateTestResultsParserFactory(unitTestResultXmlFormat, testResultsParser);
            TestRunResultParser       unitTestResultParser     = CreateUnitTestResultParser(testResultsParserFactory, unitTestResultXmlFormat);

            // Act
            TestRun testRun = unitTestResultParser.ParseXml(xmlPath);

            // Assert
            Assert.AreEqual(unitTestResultXmlFormat, unitTestResultParser.Format);
            Assert.AreSame(expectedTestRun, testRun);

            testResultsParserFactory.Received(1).CreateParser(unitTestResultXmlFormat);
            testResultsParser.Received(1).ParseXml(xmlPath);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestRunResultParser"/> class.
 /// </summary>
 /// <param name="testResultsParserFactory">The test results parser factory.</param>
 /// <param name="unitTestResultXmlFormat">The unit test result XML format.</param>
 public TestRunResultParser(ITestResultsParserFactory testResultsParserFactory, UnitTestResultXmlFormat unitTestResultXmlFormat)
 {
     Format             = unitTestResultXmlFormat;
     _testResultsParser = testResultsParserFactory.CreateParser(unitTestResultXmlFormat);
 }
        private static TestRunResultParser CreateUnitTestResultParser(ITestResultsParserFactory testResultsParserFactory, UnitTestResultXmlFormat unitTestResultXmlFormat)
        {
            TestRunResultParser unitTestResultParser = new TestRunResultParser(testResultsParserFactory, unitTestResultXmlFormat);

            return(unitTestResultParser);
        }