/// <summary> /// This method calls the Create Method on the XmlReader and puts the state in CreateSuccess or TestPass. /// It goes in PASS also if the reader threw an expected error. In all other cases it should throw /// TestFailedException. /// </summary> /// <param name="readThru">This param determines which overload to call. /// In future on multiple overloads we can make this param /// an enum which can be set using the spec file data</param> protected void CreateReader(ReadThru readThru) { // Assumption is that the Create method doesn't throw NullReferenceException and // it is not the goal of this framework to test if they are thrown anywhere. // but if they are thrown that's a problem and they shouldn't be caught but exposed. try { switch (readThru) { case ReadThru.TextReader: _factoryReader = ReaderHelper.Create(_textReader, _settings, _baseUri); break; case ReadThru.XmlReader: _factoryReader = ReaderHelper.Create(_underlyingReader, _settings); break; case ReadThru.Stream: _factoryReader = ReaderHelper.Create(_stream, _settings); break; default: throw new CTestFailedException("Unknown ReadThru type: " + readThru); } pstate = TestState.CreateSuccess; } catch (ArgumentNullException ane) { Log(ane.Message); Log(ane.StackTrace); if (!IsVariationValid) { if (!CheckException(ane)) { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Argument Null Exception Thrown in CreateMethod, is your variation data correct?"); } else { //This means that the Exception was checked and everything is fine. pstate = TestState.Pass; } } else { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Argument Null Exception Thrown in CreateMethod, is your variation data correct?"); } } }
/// <summary> /// This method calls the Create Method on the XmlReader and puts the state in CreateSuccess or TestPass. /// It goes in PASS also if the reader threw an expected error. In all other cases it should throw /// TestFailedException. /// </summary> /// <param name="readThru">This param determines which overload to call. /// In future on multiple overloads we can make this param /// an enum which can be set using the spec file data</param> protected void CreateReader(ReadThru readThru) { //Assumption is that the Create method doesnt throw NullReferenceException and //it is not the goal of this framework to test if they are thrown anywhere. //but if they are thrown thats a problem and they shouldnt be caught but exposed. try { switch (readThru) { case ReadThru.TextReader: _factoryReader = ReaderHelper.Create(_textReader, _settings, _baseUri); break; case ReadThru.XmlReader: _factoryReader = ReaderHelper.Create(_underlyingReader, _settings); break; case ReadThru.Stream: _factoryReader = ReaderHelper.Create(_stream, _settings); break; default: throw new CTestFailedException("Unknown ReadThru type: " + readThru); } pstate = TestState.CreateSuccess; } catch (ArgumentNullException ane) { Log(ane.Message); Log(ane.StackTrace); if (!IsVariationValid) { if (!CheckException(ane)) { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Argument Null Exception Thrown in CreateMethod, is your variation data correct?"); } else { //This means that the Exception was checked and everything is fine. pstate = TestState.Pass; } } else { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Argument Null Exception Thrown in CreateMethod, is your variation data correct?"); } } }