コード例 #1
0
 public BatchWriterTestDescriptor(Settings settings, WriterInvocations[] invocations, Dictionary<string, string> expectedHeaders = null, Uri baseUri = null)
 {
     this.TestDescriptorSettings = settings;
     this.invocationsAndOperationDescriptors = invocations.Select(i => new InvocationAndOperationDescriptor { Invocation = i, OperationDescriptor = null }).ToArray();
     this.expectedResultCallback = CreateExpectedResultCallback(this.invocationsAndOperationDescriptors, expectedHeaders, this.TestDescriptorSettings.ExpectedResultSettings);
     this.baseUri = baseUri;
 }
コード例 #2
0
 public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, int?maxPartsPerBatch, int?maxOperationsPerChangeset)
 {
     this.TestDescriptorSettings             = settings;
     this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
     this.expectedResultCallback             = CreateExpectedResultCallback(invocationsAndOperationDescriptors, null, this.TestDescriptorSettings.ExpectedResultSettings);
     this.maxPartsPerBatch          = maxPartsPerBatch;
     this.maxOperationsPerChangeset = maxOperationsPerChangeset;
 }
コード例 #3
0
 public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, Dictionary <string, string> expectedHeaders = null, Uri baseUri = null, IODataPayloadUriConverter urlResolver = null)
 {
     this.TestDescriptorSettings             = settings;
     this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
     this.expectedResultCallback             = CreateExpectedResultCallback(invocationsAndOperationDescriptors, expectedHeaders, this.TestDescriptorSettings.ExpectedResultSettings);
     this.baseUri     = baseUri;
     this.urlResolver = urlResolver;
 }
コード例 #4
0
 public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, Dictionary<string, string> expectedHeaders = null, Uri baseUri = null, IODataUrlResolver urlResolver = null)
 {
     this.TestDescriptorSettings = settings;
     this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
     this.expectedResultCallback = CreateExpectedResultCallback(invocationsAndOperationDescriptors, expectedHeaders, this.TestDescriptorSettings.ExpectedResultSettings);
     this.baseUri = baseUri;
     this.urlResolver = urlResolver;
 }
コード例 #5
0
 public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, int? maxPartsPerBatch, int? maxOperationsPerChangeset)
 {
     this.TestDescriptorSettings = settings;
     this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
     this.expectedResultCallback = CreateExpectedResultCallback(invocationsAndOperationDescriptors, null, this.TestDescriptorSettings.ExpectedResultSettings);
     this.maxPartsPerBatch = maxPartsPerBatch;
     this.maxOperationsPerChangeset = maxOperationsPerChangeset;
 }
コード例 #6
0
        public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, ExpectedException expectedException, Uri baseUri = null)
        {
            ExceptionUtilities.CheckArgumentNotNull(expectedException, "expectedException");

            this.TestDescriptorSettings = settings;
            this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
            this.expectedResultCallback = CreateExpectedErrorResultCallback(null, null, expectedException, this.TestDescriptorSettings.ExpectedResultSettings);
            this.baseUri = baseUri;
        }
コード例 #7
0
        public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, Exception expectedException, Uri baseUri = null)
        {
            ExceptionUtilities.CheckArgumentNotNull(expectedException, "expectedException");

            this.TestDescriptorSettings             = settings;
            this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
            this.expectedResultCallback             = CreateExpectedErrorResultCallback(null, expectedException, null, this.TestDescriptorSettings.ExpectedResultSettings);
            this.baseUri = baseUri;
        }
コード例 #8
0
 public BatchWriterTestDescriptor(Settings settings, WriterInvocations[] invocations, Dictionary <string, string> expectedHeaders = null, Uri baseUri = null)
 {
     this.TestDescriptorSettings             = settings;
     this.invocationsAndOperationDescriptors = invocations.Select(i => new InvocationAndOperationDescriptor {
         Invocation = i, OperationDescriptor = null
     }).ToArray();
     this.expectedResultCallback = CreateExpectedResultCallback(this.invocationsAndOperationDescriptors, expectedHeaders, this.TestDescriptorSettings.ExpectedResultSettings);
     this.baseUri = baseUri;
 }
コード例 #9
0
 public CollectionWriterTestDescriptor(Settings settings, string collectionName, ItemDescription[] itemDescriptions, IEdmModel model)
 {
     this.TestDescriptorSettings = settings;
     this.collectionName = collectionName;
     this.payloadItems = itemDescriptions.Select(i => i.Item).ToArray();
     bool errorOnly;
     this.invocations = CreateInvocations(payloadItems, out errorOnly);
     this.expectedResultCallback = CollectionWriterUtils.CreateExpectedResultCallback(collectionName, itemDescriptions, errorOnly, this.TestDescriptorSettings.ExpectedResultSettings);
     this.Model = model;
 }
コード例 #10
0
        public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, int?maxPartsPerBatch, int?maxOperationsPerChangeset, ExpectedException expectedException)
        {
            ExceptionUtilities.CheckArgumentNotNull(expectedException, "expectedExceptionMessage");

            this.TestDescriptorSettings             = settings;
            this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
            this.expectedResultCallback             = CreateExpectedErrorResultCallback(null, null, expectedException, this.TestDescriptorSettings.ExpectedResultSettings);
            this.maxPartsPerBatch          = maxPartsPerBatch;
            this.maxOperationsPerChangeset = maxOperationsPerChangeset;
        }
コード例 #11
0
        public CollectionWriterTestDescriptor(Settings settings, string collectionName, object[] payloadItems, ExpectedException expectedException, IEdmModel model)
        {
            this.TestDescriptorSettings = settings;
            this.collectionName         = collectionName;
            this.payloadItems           = payloadItems;
            bool errorOnly;

            this.invocations            = CreateInvocations(payloadItems, out errorOnly);
            this.expectedResultCallback = CollectionWriterUtils.CreateExpectedErrorResultCallback(collectionName, tc => expectedException, this.TestDescriptorSettings.ExpectedResultSettings);
            this.Model = model;
        }
コード例 #12
0
        public CollectionWriterTestDescriptor(Settings settings, string collectionName, ItemDescription[] itemDescriptions, IEdmModel model)
        {
            this.TestDescriptorSettings = settings;
            this.collectionName         = collectionName;
            this.payloadItems           = itemDescriptions.Select(i => i.Item).ToArray();
            bool errorOnly;

            this.invocations            = CreateInvocations(payloadItems, out errorOnly);
            this.expectedResultCallback = CollectionWriterUtils.CreateExpectedResultCallback(collectionName, itemDescriptions, errorOnly, this.TestDescriptorSettings.ExpectedResultSettings);
            this.Model = model;
        }
コード例 #13
0
        public CollectionWriterTestDescriptor(Settings settings, string collectionName, object[] payloadItems, PayloadWriterTestDescriptor.WriterTestExpectedResultCallback expectedResultCallback, IEdmModel model)
        {
            this.TestDescriptorSettings = settings;
            this.collectionName         = collectionName;
            this.payloadItems           = payloadItems;
            bool errorOnly;

            this.invocations            = CreateInvocations(payloadItems, out errorOnly);
            this.expectedResultCallback = expectedResultCallback;
            this.Model = model;
        }
コード例 #14
0
        public CollectionWriterTestDescriptor(Settings settings, string collectionName, WriterInvocations[] invocations, Func <WriterTestConfiguration, ExpectedException> expectedExceptionFunc, ItemDescription collectionItem, ItemDescription errorItem, IEdmModel model)
        {
            this.TestDescriptorSettings = settings;
            this.collectionName         = collectionName;
            ItemDescription[] itemDescriptions;
            bool errorOnly;

            this.payloadItems = CreatePayloadItems(invocations, collectionItem, errorItem, out itemDescriptions, out errorOnly);
            this.invocations  = invocations;
            this.Model        = model;

            if (expectedExceptionFunc == null)
            {
                this.expectedResultCallback = CollectionWriterUtils.CreateExpectedResultCallback(collectionName, itemDescriptions, errorOnly, this.TestDescriptorSettings.ExpectedResultSettings);
            }
            else
            {
                this.expectedResultCallback = CollectionWriterUtils.CreateExpectedErrorResultCallback(collectionName, expectedExceptionFunc, this.TestDescriptorSettings.ExpectedResultSettings);
            }
        }
コード例 #15
0
 public CollectionWriterTestDescriptor(Settings settings, string collectionName, WriterInvocations[] invocations, Func<WriterTestConfiguration, ExpectedException> expectedExceptionFunc, ItemDescription collectionItem)
 {
     this.TestDescriptorSettings = settings;
     this.collectionName = collectionName;
     ItemDescription[] itemDescriptions;
     bool errorOnly;
     this.payloadItems = CreatePayloadItems(invocations, collectionItem, null, out itemDescriptions, out errorOnly);
     this.invocations = invocations;
     if (expectedExceptionFunc == null )
     {
         // skip validation of cases that do not expect an error
         this.expectedResultCallback = testConfig => null;
     }
     else
     {
         this.expectedResultCallback =
             testConfig => new WriterTestExpectedResults(this.TestDescriptorSettings.ExpectedResultSettings) 
             { 
                 ExpectedException2 = expectedExceptionFunc(testConfig) 
             };
     }
 }
コード例 #16
0
        public CollectionWriterTestDescriptor(Settings settings, string collectionName, WriterInvocations[] invocations, Func <WriterTestConfiguration, ExpectedException> expectedExceptionFunc, ItemDescription collectionItem)
        {
            this.TestDescriptorSettings = settings;
            this.collectionName         = collectionName;
            ItemDescription[] itemDescriptions;
            bool errorOnly;

            this.payloadItems = CreatePayloadItems(invocations, collectionItem, null, out itemDescriptions, out errorOnly);
            this.invocations  = invocations;
            if (expectedExceptionFunc == null)
            {
                // skip validation of cases that do not expect an error
                this.expectedResultCallback = testConfig => null;
            }
            else
            {
                this.expectedResultCallback =
                    testConfig => new WriterTestExpectedResults(this.TestDescriptorSettings.ExpectedResultSettings)
                {
                    ExpectedException2 = expectedExceptionFunc(testConfig)
                };
            }
        }
コード例 #17
0
        public BatchWriterTestDescriptor(Settings settings, InvocationAndOperationDescriptor[] invocationsAndOperationDescriptors, int? maxPartsPerBatch, int? maxOperationsPerChangeset, ExpectedException expectedException)
        {
            ExceptionUtilities.CheckArgumentNotNull(expectedException, "expectedExceptionMessage");

            this.TestDescriptorSettings = settings;
            this.invocationsAndOperationDescriptors = invocationsAndOperationDescriptors;
            this.expectedResultCallback = CreateExpectedErrorResultCallback(null, null, expectedException, this.TestDescriptorSettings.ExpectedResultSettings);
            this.maxPartsPerBatch = maxPartsPerBatch;
            this.maxOperationsPerChangeset = maxOperationsPerChangeset;
        }
コード例 #18
0
 public CollectionWriterTestDescriptor(Settings settings, string collectionName, object[] payloadItems, ExpectedException expectedException, IEdmModel model)
 {
     this.TestDescriptorSettings = settings;
     this.collectionName = collectionName;
     this.payloadItems = payloadItems;
     bool errorOnly;
     this.invocations = CreateInvocations(payloadItems, out errorOnly);
     this.expectedResultCallback = CollectionWriterUtils.CreateExpectedErrorResultCallback(collectionName, tc => expectedException, this.TestDescriptorSettings.ExpectedResultSettings);
     this.Model = model;
 }
コード例 #19
0
 public CollectionWriterTestDescriptor(Settings settings, string collectionName, object[] payloadItems, PayloadWriterTestDescriptor.WriterTestExpectedResultCallback expectedResultCallback, IEdmModel model)
 {
     this.TestDescriptorSettings = settings;
     this.collectionName = collectionName;
     this.payloadItems = payloadItems;
     bool errorOnly;
     this.invocations = CreateInvocations(payloadItems, out errorOnly);
     this.expectedResultCallback = expectedResultCallback;
     this.Model = model;
 }
コード例 #20
0
        public void ExpandedLinkWithNullNavigationTests()
        {
            ODataNavigationLink expandedEntryLink = ObjectModelUtils.CreateDefaultCollectionLink();

            expandedEntryLink.IsCollection = false;

            ODataNavigationLink expandedEntryLink2 = ObjectModelUtils.CreateDefaultCollectionLink();

            expandedEntryLink2.IsCollection = false;
            expandedEntryLink2.Name         = expandedEntryLink2.Name + "2";

            ODataEntry defaultEntry = ObjectModelUtils.CreateDefaultEntry();
            ODataFeed  defaultFeed  = ObjectModelUtils.CreateDefaultFeed();
            ODataEntry nullEntry    = ObjectModelUtils.ODataNullEntry;

            PayloadWriterTestDescriptor.WriterTestExpectedResultCallback successCallback = (testConfiguration) =>
            {
                if (testConfiguration.Format == ODataFormat.Atom)
                {
                    return(new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                    {
                        Xml = new XElement(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataInlineElementName).ToString(),
                        FragmentExtractor = (result) =>
                        {
                            return result.Elements(TestAtomConstants.AtomXNamespace + TestAtomConstants.AtomLinkElementName)
                            .First(e => e.Element(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataInlineElementName) != null)
                            .Element(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataInlineElementName);
                        }
                    });
                }
                else
                {
                    return(new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                    {
                        Json = "null", //new JsonPrimitiveValue(null).ToText(testConfiguration.MessageWriterSettings.Indent),
                        FragmentExtractor = (result) =>
                        {
                            return JsonUtils.UnwrapTopLevelValue(testConfiguration, result).Object().Properties.First(p => p.Name == ObjectModelUtils.DefaultLinkName).Value;
                        }
                    });
                }
            };

            Func <ExpectedException, PayloadWriterTestDescriptor.WriterTestExpectedResultCallback> errorCallback = (expectedException) =>
            {
                return((testConfiguration) =>
                {
                    return new WriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                    {
                        ExpectedException2 = expectedException,
                    };
                });
            };

            var testCases = new PayloadWriterTestDescriptor <ODataItem>[]
            {
                // navigation to a null entry
                new PayloadWriterTestDescriptor <ODataItem>(
                    this.Settings,
                    new ODataItem[] { defaultEntry, expandedEntryLink, nullEntry },
                    successCallback),

                // navigation to a null entry twice
                new PayloadWriterTestDescriptor <ODataItem>(
                    this.Settings,
                    new ODataItem[] { defaultEntry, expandedEntryLink, nullEntry, null, null, expandedEntryLink2, nullEntry, null },
                    successCallback),

                // top level null entry.
                new PayloadWriterTestDescriptor <ODataItem>(
                    this.Settings,
                    new ODataItem[] { nullEntry },
                    errorCallback(new ExpectedException(typeof(ArgumentNullException)))),

                // navigation to a null entry twice in expanded link
                // this actually throws ArgumentNullException when WriteStart() for the second nullEntry is called since
                // the state has been changed from NavigationLink to ExpandedLink after the first one.
                // TODO: check if ArgumentNullException needs to change the WriterState.
                new PayloadWriterTestDescriptor <ODataItem>(
                    this.Settings,
                    new ODataItem[] { defaultEntry, expandedEntryLink, nullEntry, null, nullEntry },
                    errorCallback(new ExpectedException(typeof(ArgumentNullException)))),

                // Null entry inside a feed, same as above this throws ArgumentNullException but state is not put to error state.
                new PayloadWriterTestDescriptor <ODataItem>(
                    this.Settings,
                    new ODataItem[] { defaultFeed, nullEntry },
                    errorCallback(new ExpectedException(typeof(ArgumentNullException)))),
            };

            // TODO: Fix places where we've lost JsonVerbose coverage to add JsonLight
            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent.Where(tc => tc.Format == ODataFormat.Atom),
                (testCase, testConfig) =>
            {
                testConfig = testConfig.Clone();
                testConfig.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri);

                TestWriterUtils.WriteAndVerifyODataPayload(testCase, testConfig, this.Assert, this.Logger);
            });
        }
コード例 #21
0
        public void EntityReferenceLinksPropertyAccessOrderTest()
        {
            //// NOTE: this tests is important as Astoria relies on this behavior. Astoria only provides a next link after all the entity reference
            ////       links have been written so we must not access the next link before that point.

            ODataEntityReferenceLink entityReferenceLink1 = new ODataEntityReferenceLink {
                Url = new Uri("http://odata.org/linkresult1")
            };
            ODataEntityReferenceLink entityReferenceLink2 = new ODataEntityReferenceLink {
                Url = new Uri("http://odata.org/linkresult2")
            };
            ODataEntityReferenceLink entityReferenceLink3 = new ODataEntityReferenceLink {
                Url = new Uri("http://odata.org/linkresult3")
            };

            Uri  nextPageLink          = new Uri("http://odata.org/nextpage");
            Uri  incorrectNextPageLink = new Uri("http://odata.org/incorrectnextpage");
            long correctCountValue     = 3;

            // the expected result instance
            ODataEntityReferenceLinks expectedResult = new ODataEntityReferenceLinks
            {
                Count        = 3,
                Links        = new ODataEntityReferenceLink[] { entityReferenceLink1, entityReferenceLink2, entityReferenceLink3 },
                NextPageLink = nextPageLink
            };

            PayloadWriterTestDescriptor.WriterTestExpectedResultCallback expectedResultCallback = this.CreateExpectedCallback(expectedResult, /*forceNextLinkAndCountAtEnd*/ true);

            this.CombinatorialEngineProvider.RunCombinations(
                this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent.Where(tc => !tc.IsRequest),
                (testConfiguration) =>
            {
                testConfiguration = testConfiguration.Clone();
                testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri);

                // The instance with the proper inline count set but an incorrect next link; as we enumerate the links themselves
                // we will invalidate the inline count and set the correct next link to guarantee the correct order of property accesses
                // NOTE: we need to create this new for each iteration since the checking enumerable can (intentionally) only be enumerated once.
                ODataEntityReferenceLinks testReferenceLink = new ODataEntityReferenceLinks
                {
                    Count = correctCountValue,
                    // In JSON lite, we will write the next link first if one is available.  Otherwise, we'll write it at the end.
                    NextPageLink = testConfiguration.Format == ODataFormat.Json ? null : incorrectNextPageLink
                };
                testReferenceLink.Links = new CheckingEntityReferenceLinkEnumerable(
                    testReferenceLink,
                    correctCountValue,
                    nextPageLink /* correct next link */,
                    entityReferenceLink1,
                    entityReferenceLink2,
                    entityReferenceLink3);

                PayloadWriterTestDescriptor <ODataEntityReferenceLinks> testDescriptor =
                    new PayloadWriterTestDescriptor <ODataEntityReferenceLinks>(this.Settings, testReferenceLink, expectedResultCallback);

                IEdmNavigationProperty navProp = null;
                IEdmEntitySet entitySet        = null;
                // When writing JSON lite, always provide a model and a non-null nav prop.
                // The error cases when a model isn't provided or the nav prop is null are tested in JsonLightEntityReferenceLinkWriterTests
                if (testConfiguration.Format == ODataFormat.Json)
                {
                    testDescriptor.Model = CreateModelWithNavProps();
                    var edmModel         = testDescriptor.GetMetadataProvider();
                    navProp   = GetCollectionNavProp(edmModel);
                    entitySet = GetCollectionEntitySet(edmModel);
                }

                ODataEntityReferenceLinks entityReferenceLinks = testDescriptor.PayloadItems.Single();

                TestWriterUtils.WriteAndVerifyTopLevelContent(
                    testDescriptor,
                    testConfiguration,
                    (messageWriter) => messageWriter.WriteEntityReferenceLinks(entityReferenceLinks),
                    this.Assert,
                    baselineLogger: this.Logger);
            });
        }
コード例 #22
0
        public void ParameterWriterStateMachineErrorTests()
        {
            var testCases = new ParameterWriterStateMachineTestCase[]
            {
                // WriteStart can only be called once and it must be called before writing anything else.
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.WriteStart();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteStart"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.WriteValue("p1", null);
                        writer.WriteStart();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteStart"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.CreateCollectionWriter("p1");
                        writer.WriteStart();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteStart"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.WriteEnd();
                        writer.WriteStart();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteStart"),
                },

                // WriteValue and CreateCollectionWriter can only be called after WriteStart and before WriteEnd. And they cannot be called until the previously created sub-writer is completed.
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteValue("p1", null);
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteParameter"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.CreateCollectionWriter("p1");
                        writer.WriteValue("p1", null);
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteParameter"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.CreateCollectionWriter("p1");
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteParameter"),
                },

                // WriteEnd can only be called after WriteStart and after the previously created sub-writer is completed.
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteEnd();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteEnd"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.CreateCollectionWriter("p1");
                        writer.WriteEnd();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteEnd"),
                },

                // The writer is in error or completed state. No further writes can be performed on this writer.
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.WriteEnd();
                        writer.WriteValue("p1", null);
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteInErrorOrCompletedState"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.WriteEnd();
                        writer.CreateCollectionWriter("p1");
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteInErrorOrCompletedState"),
                },
                new ParameterWriterStateMachineTestCase
                {
                    WriteActions = writer =>
                    {
                        writer.WriteStart();
                        writer.WriteEnd();
                        writer.WriteEnd();
                    },
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataParameterWriterCore_CannotWriteInErrorOrCompletedState"),
                },
                // TODO: Add test cases to cause the writer enter error state then verify that no writes can be performed afterwards.
            };

            var testConfigurations = this.WriterTestConfigurationProvider.JsonLightFormatConfigurations.Where(tc => tc.IsRequest);

            this.CombinatorialEngineProvider.RunCombinations(testConfigurations, testCases, (testConfiguration, testCase) =>
            {
                PayloadWriterTestDescriptor.WriterTestExpectedResultCallback resultCallback = testConfig => new JsonWriterTestExpectedResults(this.Settings.ExpectedResultSettings)
                {
                    ExpectedException2 = testCase.ExpectedException
                };
                var testDescriptor = new PayloadWriterTestDescriptor <ODataParameters>(this.Settings, ObjectModelUtils.CreateDefaultParameter(), resultCallback);

                TestWriterUtils.WriteActionAndVerifyODataPayload <ODataParameters>(
                    (messageWriter, writerDescriptor, feedWriter) =>
                {
                    ODataParameterWriter writer = messageWriter.CreateODataParameterWriter(null /*functionImport*/);
                    testCase.WriteActions(writer);
                },
                    testDescriptor,
                    testConfiguration,
                    this.Assert,
                    this.Logger);
            });
        }
コード例 #23
0
 public CollectionWriterTestDescriptor(Settings settings, string collectionName, string collectionTypeName, object[] payloadItems, PayloadWriterTestDescriptor.WriterTestExpectedResultCallback expectedResultCallback, IEdmModel model)
     : this(settings, collectionName, payloadItems, expectedResultCallback, model)
 {
     this.collectionTypeName = collectionTypeName;
 }
コード例 #24
0
        public CollectionWriterTestDescriptor(Settings settings, string collectionName, WriterInvocations[] invocations, Func<WriterTestConfiguration, ExpectedException> expectedExceptionFunc, ItemDescription collectionItem, ItemDescription errorItem, IEdmModel model)
        {
            this.TestDescriptorSettings = settings;
            this.collectionName = collectionName;
            ItemDescription[] itemDescriptions;
            bool errorOnly;
            this.payloadItems = CreatePayloadItems(invocations, collectionItem, errorItem, out itemDescriptions, out errorOnly);
            this.invocations = invocations;
            this.Model = model;

            if (expectedExceptionFunc == null)
            {
                this.expectedResultCallback = CollectionWriterUtils.CreateExpectedResultCallback(collectionName, itemDescriptions, errorOnly, this.TestDescriptorSettings.ExpectedResultSettings);
            }
            else
            {
                this.expectedResultCallback = CollectionWriterUtils.CreateExpectedErrorResultCallback(collectionName, expectedExceptionFunc, this.TestDescriptorSettings.ExpectedResultSettings);
            }
        }