public override void RunTest(ReaderTestConfiguration testConfiguration) { //TODO: Use Logger to verify result, right now this change is only to unblock writer testcase checkin BaselineLogger logger = null; if (this.ShouldSkipForTestConfiguration(testConfiguration)) { return; } var originalPayload = this.PayloadElement; this.PayloadElement = this.PayloadElement.DeepCopy(); // Create messages (payload gets serialized in createInputMessage) TestMessage readerMessage = this.CreateInputMessage(testConfiguration); var settings = new ODataMessageWriterSettings() { Version = testConfiguration.Version, BaseUri = testConfiguration.MessageReaderSettings.BaseUri, EnableMessageStreamDisposal = testConfiguration.MessageReaderSettings.EnableMessageStreamDisposal, }; settings.SetContentType(testConfiguration.Format); WriterTestConfiguration writerConfig = new WriterTestConfiguration(testConfiguration.Format, settings, testConfiguration.IsRequest, testConfiguration.Synchronous); TestMessage writerMessage = TestWriterUtils.CreateOutputMessageFromStream(new TestStream(new MemoryStream()), writerConfig, this.PayloadKind, String.Empty, this.UrlResolver); IEdmModel model = this.GetMetadataProvider(testConfiguration); WriterTestExpectedResults expectedResult = this.GetExpectedResult(writerConfig); ExceptionUtilities.Assert(expectedResult != null, "The expected result could not be determined for the test. Did you specify it?"); Exception exception = TestExceptionUtils.RunCatching(() => { using (ODataMessageReaderTestWrapper messageReaderWrapper = TestReaderUtils.CreateMessageReader(readerMessage, model, testConfiguration)) using (ODataMessageWriterTestWrapper messageWriterWrapper = TestWriterUtils.CreateMessageWriter(writerMessage, model, writerConfig, this.settings.Assert)) { var streamer = new ObjectModelReadWriteStreamer(); streamer.StreamMessage(messageReaderWrapper, messageWriterWrapper, this.PayloadKind, writerConfig); expectedResult.VerifyResult(writerMessage, this.PayloadKind, writerConfig, logger); } }); this.PayloadElement = originalPayload; try { expectedResult.VerifyException(exception); } catch (Exception) { this.TraceFailureInformation(testConfiguration); throw; } }
public override void RunTest(ReaderTestConfiguration testConfiguration) { //TODO: Use Logger to verify result, right now this change is only to unblock writer testcase checkin BaselineLogger logger = null; if (this.ShouldSkipForTestConfiguration(testConfiguration)) { return; } var originalPayload = this.PayloadElement; this.PayloadElement = this.PayloadElement.DeepCopy(); if (testConfiguration.Format == ODataFormat.Atom) { this.PayloadElement.Accept(new AddFeedIDFixup()); this.PayloadElement.Accept(new WriteFeedIDFirstFixup()); } // Create messages (payload gets serialized in createInputMessage) TestMessage readerMessage = this.CreateInputMessage(testConfiguration); var settings = new ODataMessageWriterSettings() { Version = testConfiguration.Version, PayloadBaseUri = testConfiguration.MessageReaderSettings.BaseUri, DisableMessageStreamDisposal = testConfiguration.MessageReaderSettings.DisableMessageStreamDisposal, }; settings.SetContentType(testConfiguration.Format); WriterTestConfiguration writerConfig = new WriterTestConfiguration(testConfiguration.Format, settings, testConfiguration.IsRequest, testConfiguration.Synchronous); TestMessage writerMessage = TestWriterUtils.CreateOutputMessageFromStream(new TestStream(new MemoryStream()), writerConfig, this.PayloadKind, String.Empty, this.UrlResolver); IEdmModel model = this.GetMetadataProvider(testConfiguration); WriterTestExpectedResults expectedResult = this.GetExpectedResult(writerConfig); ExceptionUtilities.Assert(expectedResult != null, "The expected result could not be determined for the test. Did you specify it?"); Exception exception = TestExceptionUtils.RunCatching(() => { using (ODataMessageReaderTestWrapper messageReaderWrapper = TestReaderUtils.CreateMessageReader(readerMessage, model, testConfiguration)) using (ODataMessageWriterTestWrapper messageWriterWrapper = TestWriterUtils.CreateMessageWriter(writerMessage, model, writerConfig, this.settings.Assert)) { var streamer = new ObjectModelReadWriteStreamer(); streamer.StreamMessage(messageReaderWrapper, messageWriterWrapper, this.PayloadKind, writerConfig); expectedResult.VerifyResult(writerMessage, this.PayloadKind, writerConfig, logger); } }); this.PayloadElement = originalPayload; try { expectedResult.VerifyException(exception); } catch (Exception) { this.TraceFailureInformation(testConfiguration); throw; } }