示例#1
0
        private void InvokeBatchWriterAction(
            ODataBatchWriterTestWrapper writer,
            BatchWriterAction writerAction,
            WriterTestConfiguration testConfiguration,
            bool readOperationReady,
            BatchWriterStatesTestSetupResult setupResult)
        {
            switch (writerAction)
            {
            case BatchWriterAction.StartBatch:
                writer.WriteStartBatch();
                break;

            case BatchWriterAction.EndBatch:
                writer.WriteEndBatch();
                break;

            case BatchWriterAction.StartChangeset:
                writer.WriteStartChangeset();
                break;

            case BatchWriterAction.EndChangeset:
                writer.WriteEndChangeset();
                break;

            case BatchWriterAction.Operation:
                if (testConfiguration.IsRequest)
                {
                    writer.CreateOperationRequestMessage(readOperationReady ? "GET" : "POST", new Uri("http://odata.org"), "4");
                }
                else
                {
                    writer.CreateOperationResponseMessage();
                }

                break;

            case BatchWriterAction.GetOperationStream:
                GetOperationStream(setupResult == null ? null : setupResult.Message, testConfiguration);
                break;

            case BatchWriterAction.DisposeOperationStream:
                Stream s = setupResult == null ? null : setupResult.MessageStream;
                if (s != null)
                {
                    try
                    {
                        s.Dispose();
                    }
                    catch (ObjectDisposedException e)
                    {
                        // Replace the disposed exception with OData exception so that our type checks work correctly.
                        // No need to verify that the Dispose thrown the right type of the exception.
                        throw new ODataException(e.Message);
                    }
                }
                break;
            }
        }
        private void InvokeBatchWriterAction(
            ODataBatchWriterTestWrapper writer,
            BatchWriterAction writerAction,
            WriterTestConfiguration testConfiguration,
            bool readOperationReady,
            BatchWriterStatesTestSetupResult setupResult)
        {
            switch (writerAction)
            {
                case BatchWriterAction.StartBatch:
                    writer.WriteStartBatch();
                    break;
                case BatchWriterAction.EndBatch:
                    writer.WriteEndBatch();
                    break;
                case BatchWriterAction.StartChangeset:
                    writer.WriteStartChangeset();
                    break;
                case BatchWriterAction.EndChangeset:
                    writer.WriteEndChangeset();
                    break;
                case BatchWriterAction.Operation:
                    if (testConfiguration.IsRequest)
                    {
                        writer.CreateOperationRequestMessage(readOperationReady ? "GET" : "POST", new Uri("http://odata.org"), "4");
                    }
                    else
                    {
                        writer.CreateOperationResponseMessage();
                    }

                    break;
                case BatchWriterAction.GetOperationStream:
                    GetOperationStream(setupResult == null ? null : setupResult.Message, testConfiguration);
                    break;
                case BatchWriterAction.DisposeOperationStream:
                    Stream s = setupResult == null ? null : setupResult.MessageStream;
                    if (s != null)
                    {
                        try
                        {
                            s.Dispose();
                        }
                        catch (ObjectDisposedException e)
                        {
                            // Replace the disposed exception with OData exception so that our type checks work correctly.
                            // No need to verify that the Dispose thrown the right type of the exception.
                            throw new ODataException(e.Message);
                        }
                    }
                    break;
            }
        }