[Ignore] // Remove Atom
        // [TestMethod, Variation(Description = "Verifies that sync and async calls cannot be mixed on a single writer.")]
        public void SyncAsyncMismatchTest()
        {
            // ToDo: Fix places where we've lost JsonVerbose coverage to add JsonLight
            this.CombinatorialEngineProvider.RunCombinations(
                TestCalls,
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurations.Where(tc => false),
                new bool[] { false, true },
                new bool[] { false, true },
                (testCall, testConfiguration, writingFeed, testSynchronousCall) =>
            {
                testConfiguration = testConfiguration.Clone();
                testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri);

                using (TestStream memoryStream = new TestStream())
                {
                    // We purposely don't use the using pattern around the messageWriter here. Disposing the message writer will
                    // fail here because the writer is not left in a valid state.
                    var messageWriter = TestWriterUtils.CreateMessageWriter(memoryStream, testConfiguration, this.Assert);

                    // Note that the CreateODataWriter call will call either sync or async variant based on the testConfiguration
                    // which is independent axis to the testSynchronousCall and thus we will end up with async creation but sync write
                    // and vice versa.
                    ODataWriter odataWriter       = messageWriter.CreateODataWriter(writingFeed);
                    ODataWriterTestWrapper writer = (ODataWriterTestWrapper)odataWriter;
                    if (testCall.AssumesFeedWriter)
                    {
                        if (!writingFeed)
                        {
                            // Skip this case since we need feed writer for this case.
                            return;
                        }
                    }
                    else
                    {
                        if (writingFeed)
                        {
                            writer.WriteStart(ObjectModelUtils.CreateDefaultFeed());
                        }
                    }

                    this.Assert.ExpectedException <ODataException>(
                        () =>
                    {
                        if (testSynchronousCall)
                        {
                            testCall.Sync(writer);
                        }
                        else
                        {
                            testCall.Async(writer);
                        }
                    },
                        testConfiguration.Synchronous == testSynchronousCall ?
                        null :
                        testSynchronousCall ?
                        "A synchronous operation was called on an asynchronous writer. Calls on a writer instance must be either all synchronous or all asynchronous." :
                        "An asynchronous operation was called on a synchronous writer. Calls on a writer instance must be either all synchronous or all asynchronous.");
                }
            });
        }
Пример #2
0
            public ODataWriterCoreInspector(ODataWriter writer)
            {
                ODataWriterTestWrapper writerTestWrapper = writer as ODataWriterTestWrapper;

                this.writer = writerTestWrapper == null ? writer : writerTestWrapper.Writer;
            }