protected void CreateWriter(WriteThru writeThru) { // 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. Log("Writing thru : " + writeThru); try { switch (writeThru) { case WriteThru.Stream: _factoryWriter = WriterHelper.Create(_stream, _settings); break; case WriteThru.StringBuilder: _factoryWriter = WriterHelper.Create(_stringBuilder, _settings); break; case WriteThru.TextWriter: _factoryWriter = WriterHelper.Create(_textWriter, _settings); break; case WriteThru.XmlWriter: _factoryWriter = WriterHelper.Create(_underlyingWriter, _settings); break; } pstate = TestState.CreateSuccess; } catch (Exception ane) { Log(ane.ToString()); if (!IsVariationValid) { if (!CheckException(ane)) { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "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 valid variation threw exception else { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Exception Thrown in CreateMethod, is your variation data correct?"); } } }
protected void CreateWriter(WriteThru writeThru) { //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. Log("Writing thru : " + writeThru); try { switch (writeThru) { case WriteThru.Stream: _factoryWriter = WriterHelper.Create(_stream, _settings); break; case WriteThru.StringBuilder: _factoryWriter = WriterHelper.Create(_stringBuilder, _settings); break; case WriteThru.TextWriter: _factoryWriter = WriterHelper.Create(_textWriter, _settings); break; case WriteThru.XmlWriter: _factoryWriter = WriterHelper.Create(_underlyingWriter, _settings); break; } pstate = TestState.CreateSuccess; } catch (Exception ane) { Log(ane.ToString()); if (!IsVariationValid) { if (!CheckException(ane)) { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "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 valid variation threw exception else { pstate = TestState.Error; DumpVariationInfo(); throw new CTestFailedException( "Exception Thrown in CreateMethod, is your variation data correct?"); } } }