public void PropertySettersNullTest() { ODataServiceDocument serviceDocument = new ODataServiceDocument(); serviceDocument.EntitySets = null; this.Assert.IsNull(serviceDocument.EntitySets, "Expected null value for property 'EntitySets'."); }
/// <summary> /// Generate a default ODataServiceDocument instance from model. /// </summary> /// <param name="model">The Edm Model frm which to generate the service document.</param> /// <returns>The generated service document.</returns> public static ODataServiceDocument GenerateServiceDocument(this IEdmModel model) { ExceptionUtils.CheckArgumentNotNull(model, "model"); if (model.EntityContainer == null) { throw new ODataException(Strings.ODataUtils_ModelDoesNotHaveContainer); } ODataServiceDocument serviceDocument = new ODataServiceDocument(); serviceDocument.EntitySets = model.EntityContainer.EntitySets() .Select(entitySet => new ODataEntitySetInfo() { Name = entitySet.Name, Title = entitySet.Name, Url = new Uri(entitySet.Name, UriKind.RelativeOrAbsolute) }).ToList(); serviceDocument.Singletons = model.EntityContainer.Singletons() .Select(singleton => new ODataSingletonInfo() { Name = singleton.Name, Title = singleton.Name, Url = new Uri(singleton.Name, UriKind.RelativeOrAbsolute) }).ToList(); serviceDocument.FunctionImports = model.EntityContainer.OperationImports().OfType <IEdmFunctionImport>().Where(functionImport => functionImport.IncludeInServiceDocument) .Select(functionImport => new ODataFunctionImportInfo() { Name = functionImport.Name, Title = functionImport.Name, Url = new Uri(functionImport.Name, UriKind.RelativeOrAbsolute) }).ToList(); return(serviceDocument); }
public ODataServiceDocument GetServiceDocument() { IEdmModel model = GetModel(); ODataServiceDocument serviceDocument = new ODataServiceDocument(); IEdmEntityContainer container = model.EntityContainer; // Add EntitySets into service document serviceDocument.EntitySets = container.EntitySets().Select( e => GetODataEntitySetInfo(model.GetNavigationSourceUrl(e).ToString(), e.Name)); // Add Singletons into the service document IEnumerable<IEdmSingleton> singletons = container.Elements.OfType<IEdmSingleton>(); serviceDocument.Singletons = singletons.Select( e => GetODataSingletonInfo(model.GetNavigationSourceUrl(e).ToString(), e.Name)); // Add FunctionImports into service document // ODL spec says: // The edm:FunctionImport for a parameterless function MAY include the IncludeInServiceDocument attribute // whose Boolean value indicates whether the function import is advertised in the service document. // If no value is specified for this attribute, its value defaults to false. // Find all parameterless functions with "IncludeInServiceDocument = true" IEnumerable<IEdmFunctionImport> functionImports = container.Elements.OfType<IEdmFunctionImport>() .Where(f => !f.Function.Parameters.Any() && f.IncludeInServiceDocument); serviceDocument.FunctionImports = functionImports.Distinct(new FunctionImportComparer()) .Select(f => GetODataFunctionImportInfo(f.Name)); return serviceDocument; }
public void PropertyGettersAndSettersTest() { ODataEntitySetInfo collection1 = new ODataEntitySetInfo(); ODataEntitySetInfo collection2 = new ODataEntitySetInfo(); ODataEntitySetInfo collection3 = new ODataEntitySetInfo(); ODataEntitySetInfo[] collections = new ODataEntitySetInfo[] { collection1, collection2, collection3 }; ODataServiceDocument serviceDocument = new ODataServiceDocument() { EntitySets = collections }; this.Assert.AreSame(collections, serviceDocument.EntitySets, "Expected reference equal values for property 'EntitySets'."); }
public ODataServiceDocument GetServiceDocument() { IEdmModel model = GetModel(); ODataServiceDocument serviceDocument = new ODataServiceDocument(); IEdmEntityContainer container = model.EntityContainers().Single(); // Add Entitysets into service document serviceDocument.EntitySets = container.EntitySets().Select( e => GetODataEntitySetInfo(model.GetEntitySetUrl(e).ToString(), e.Name)); // TODO: 1637 Add Singletons to service document // Add FunctionImports into service document IEnumerable<IEdmFunctionImport> functionImports = container.Elements.OfType<IEdmFunctionImport>() .Where(f => f.IncludeInServiceDocument); serviceDocument.FunctionImports = functionImports.Select( e => GetODataFunctionImportInfo(e.Name)); return serviceDocument; }
/// <summary>Writes the Service Document to the output stream.</summary> /// <param name="provider">DataServiceProviderWrapper instance.</param> internal void WriteServiceDocument(DataServiceProviderWrapper provider) { ODataServiceDocument serviceDocument = new ODataServiceDocument(); serviceDocument.EntitySets = provider.GetResourceSets().Select(rs => { ODataEntitySetInfo entitySetInfo = new ODataEntitySetInfo() { Url = new Uri(rs.Name, UriKind.RelativeOrAbsolute), Name = rs.Name }; entitySetInfo.SetAnnotation<AtomResourceCollectionMetadata>(new AtomResourceCollectionMetadata() { Title = new AtomTextConstruct { Text = rs.Name } }); return entitySetInfo; }); this.writer.WriteServiceDocument(serviceDocument); }
public void CategoryMetadataOnWorkspaceCollectionCategoriesWriterTest() { var testCases = this.CreateAtomCategoryTestCases(); // Convert test cases to test descriptions var testDescriptors = testCases.Select(testCase => { AtomResourceCollectionMetadata metadata = new AtomResourceCollectionMetadata { Categories = new AtomCategoriesMetadata { Categories = new[] { testCase.Category } } }; ODataEntitySetInfo collection = new ODataEntitySetInfo { Url = new Uri("http://odata.org/collection") }; collection.SetAnnotation(metadata); ODataServiceDocument serviceDocument = new ODataServiceDocument { EntitySets = new[] { collection } }; return new PayloadWriterTestDescriptor<ODataServiceDocument>( this.Settings, serviceDocument, testConfiguration => new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings) { Xml = testCase.Xml, ExpectedException2 = testCase.ExpectedException, FragmentExtractor = result => result .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingWorkspaceElementName) .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingCollectionElementName) .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingCategoriesElementName) .Element(TestAtomConstants.AtomXNamespace + TestAtomConstants.AtomCategoryElementName) }); }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.WriterTestConfigurationProvider.AtomFormatConfigurations.Where(tc => !tc.IsRequest), (testDescriptor, testConfiguration) => { testConfiguration = testConfiguration.Clone(); testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri); TestWriterUtils.WriteAndVerifyTopLevelContent( testDescriptor, testConfiguration, (messageWriter) => messageWriter.WriteServiceDocument(testDescriptor.PayloadItems.Single()), this.Assert, baselineLogger:this.Logger); }); }
/// <summary> /// Writes a service document with the specified <paramref name="serviceDocument"/> /// as message payload. /// </summary> /// <param name="serviceDocument">The default serviceDocument to write in the service document.</param> public void WriteServiceDocument(ODataServiceDocument serviceDocument) { if (this.testConfiguration.Synchronous) { this.messageWriter.WriteServiceDocument(serviceDocument); } else { #if SILVERLIGHT throw new TaupoNotSupportedException("This test is not supported in aSynchronous mode in Silverlight"); #else this.messageWriter.WriteServiceDocumentAsync(serviceDocument).Wait(); #endif } }
/// <summary> /// Visits a serviceDocument item. /// </summary> /// <param name="serviceDocument">The serviceDocument item to visit.</param> /// <returns>An ODataPayloadElement representing a service document enclosing the serviceDocument.</returns> protected override ODataPayloadElement VisitWorkspace(ODataServiceDocument serviceDocument) { ExceptionUtilities.CheckArgumentNotNull(serviceDocument, "serviceDocument"); ServiceDocumentInstance wrappingServiceDocumentInstance = (ServiceDocumentInstance)base.VisitWorkspace(serviceDocument); WorkspaceInstance workspaceInstance = wrappingServiceDocumentInstance.Workspaces.Single(); AtomWorkspaceMetadata atomMetadata = serviceDocument.GetAnnotation<AtomWorkspaceMetadata>(); if (atomMetadata != null) { if (atomMetadata.Title != null) { workspaceInstance.Title = atomMetadata.Title.Text; workspaceInstance.AtomTitle(atomMetadata.Title.Text, ToString(atomMetadata.Title.Kind)); } } return wrappingServiceDocumentInstance; }
/// <summary> /// Visits a service document. /// </summary> /// <param name="serviceDocument">The service document to visit.</param> protected override void VisitServiceDocument(ODataServiceDocument serviceDocument) { this.VisitAtomMetadata(serviceDocument.GetAnnotation<AtomWorkspaceMetadata>()); base.VisitServiceDocument(serviceDocument); }
public void ServiceDocument() { foreach (ODataFormat mimeType in mimeTypes) { string payload, contentType; this.WriteAndValidateContextUri(mimeType, model, omWriter => { ODataServiceDocument serviceDocument = new ODataServiceDocument(); serviceDocument.EntitySets = new ODataEntitySetInfo[] { new ODataEntitySetInfo { Name = "People", Url = new Uri(TestBaseUri + "People") } }; omWriter.WriteServiceDocument(serviceDocument); }, string.Format("\"{0}$metadata\"", TestBaseUri), out payload, out contentType); this.ReadPayload(payload, contentType, model, omReader => omReader.ReadServiceDocument()); } }
private static Action WriteServiceDocumentShouldError(ODataServiceDocument serviceDocument, IODataUrlResolver urlResolver = null) { MemoryStream memoryStream = new MemoryStream(); var serializer = CreateODataJsonLightServiceDocumentSerializer(memoryStream, urlResolver); return () => serializer.WriteServiceDocument(serviceDocument); }
private static void WriteServiceDocumentVerifyOutput(ODataServiceDocument serviceDocument, string expectedOutput) { MemoryStream memoryStream = new MemoryStream(); var serializer = CreateODataJsonLightServiceDocumentSerializer(memoryStream); serializer.WriteServiceDocument(serviceDocument); serializer.JsonWriter.Flush(); string actualResult = Encoding.UTF8.GetString(memoryStream.ToArray()); actualResult.Should().Be(expectedOutput); }
/// <summary> /// Asynchronously writes a service document with the specified <paramref name="serviceDocument"/> /// as message payload. /// </summary> /// <param name="serviceDocument">The service document to write in the service document.</param> /// <returns>A task representing the asynchronous operation of writing the service document.</returns> /// <remarks>It is the responsibility of this method to flush the output before the task finishes.</remarks> internal virtual Task WriteServiceDocumentAsync(ODataServiceDocument serviceDocument) { throw this.CreatePayloadKindNotSupportedException(ODataPayloadKind.ServiceDocument); }
public void DefaultValuesTest() { ODataServiceDocument serviceDocument = new ODataServiceDocument(); this.Assert.IsNull(serviceDocument.EntitySets, "Expected null default value for property 'EntitySets'."); }
private void WriteServiceDocument(ODataMessageWriterTestWrapper messageWriter, ODataServiceDocument serviceDocument) { messageWriter.WriteServiceDocument(serviceDocument); }
public void AtomResourceCollectionMetadataTest() { var testCases = new[] { // No title specified - an empty one is used as it's required by the spec. new { CustomizeMetadata = (Action<ODataEntitySetInfo>)(collection => { AtomResourceCollectionMetadata metadata = collection.Atom(); }), Xml = "<Collection><title xmlns='http://www.w3.org/2005/Atom'/></Collection>" }, // Simple title (other titles are tested in AtomTextConstructMetadataTests) new { CustomizeMetadata = (Action<ODataEntitySetInfo>)(collection => { AtomResourceCollectionMetadata metadata = collection.Atom(); metadata.Title = new AtomTextConstruct { Text = "collection title" }; }), Xml = "<Collection><title type='text' xmlns='http://www.w3.org/2005/Atom'>collection title</title></Collection>" }, // With accept new { CustomizeMetadata = (Action<ODataEntitySetInfo>)(collection => { AtomResourceCollectionMetadata metadata = collection.Atom(); metadata.Title = "collection title"; metadata.Accept = "mime/type"; }), Xml = "<Collection><title type='text' xmlns='http://www.w3.org/2005/Atom'>collection title</title><accept xmlns='http://www.w3.org/2007/app'>mime/type</accept></Collection>" }, // With empty accept new { CustomizeMetadata = (Action<ODataEntitySetInfo>)(collection => { AtomResourceCollectionMetadata metadata = collection.Atom(); metadata.Title = "collection title"; metadata.Accept = string.Empty; }), Xml = "<Collection><title type='text' xmlns='http://www.w3.org/2005/Atom'>collection title</title><accept xmlns='http://www.w3.org/2007/app'></accept></Collection>" }, // With categories new { CustomizeMetadata = (Action<ODataEntitySetInfo>)(collection => { AtomResourceCollectionMetadata metadata = collection.Atom(); metadata.Title = "collection title"; metadata.Categories = new AtomCategoriesMetadata(); }), Xml = "<Collection><title type='text' xmlns='http://www.w3.org/2005/Atom'>collection title</title><categories xmlns='http://www.w3.org/2007/app' /></Collection>" }, // With accept and categories new { CustomizeMetadata = (Action<ODataEntitySetInfo>)(collection => { AtomResourceCollectionMetadata metadata = collection.Atom(); metadata.Title = "collection title"; metadata.Accept = "mime/type"; metadata.Categories = new AtomCategoriesMetadata(); }), Xml = "<Collection><title type='text' xmlns='http://www.w3.org/2005/Atom'>collection title</title><accept xmlns='http://www.w3.org/2007/app'>mime/type</accept><categories xmlns='http://www.w3.org/2007/app' /></Collection>" }, }; Func<ODataEntitySetInfo>[] collectionCreators = new Func<ODataEntitySetInfo>[] { () => new ODataEntitySetInfo { Url = new Uri("http://odata.org/url") }, () => { var collection = new ODataEntitySetInfo { Url = new Uri("http://odata.org/url") }; collection.SetAnnotation(new AtomResourceCollectionMetadata()); return collection; } }; var testDescriptors = testCases.SelectMany(testCase => collectionCreators.Select(collectionCreator => { ODataEntitySetInfo collection = collectionCreator(); testCase.CustomizeMetadata(collection); ODataServiceDocument serviceDocument = new ODataServiceDocument { EntitySets = new[] { collection } }; return new PayloadWriterTestDescriptor<ODataServiceDocument>( this.Settings, new[] { serviceDocument }, tc => new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings) { Xml = testCase.Xml, FragmentExtractor = result => new XElement("Collection", result .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingWorkspaceElementName) .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingCollectionElementName) .Elements()) }); })); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.WriterTestConfigurationProvider.AtomFormatConfigurations.Where(tc => !tc.IsRequest), (testDescriptor, testConfiguration) => { testConfiguration = testConfiguration.Clone(); testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri); TestWriterUtils.WriteAndVerifyTopLevelContent( testDescriptor, testConfiguration, (messageWriter) => messageWriter.WriteServiceDocument(testDescriptor.PayloadItems.Single()), this.Assert, baselineLogger: this.Logger); }); }
public void AtomCategoriesMetadataTest() { var testCases = new [] { // Empty categories new { CategoriesMetadata = new AtomCategoriesMetadata(), Xml = "<categories xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with href new { CategoriesMetadata = new AtomCategoriesMetadata() { Href = new Uri("http://odata.org/href") }, Xml = "<categories href='http://odata.org/href' xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with href and non-null empty categories (null and empty collection should be treated the same) new { CategoriesMetadata = new AtomCategoriesMetadata() { Href = new Uri("http://odata.org/href"), Categories = new AtomCategoryMetadata[0] }, Xml = "<categories href='http://odata.org/href' xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with fixed yes new { CategoriesMetadata = new AtomCategoriesMetadata() { Fixed = true }, Xml = "<categories fixed='yes' xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with fixed no new { CategoriesMetadata = new AtomCategoriesMetadata() { Fixed = false }, Xml = "<categories fixed='no' xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with scheme new { CategoriesMetadata = new AtomCategoriesMetadata() { Scheme = "http://odata.org/scheme" }, Xml = "<categories scheme='http://odata.org/scheme' xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with scheme and fixed new { CategoriesMetadata = new AtomCategoriesMetadata() { Fixed = true, Scheme = "http://odata.org/scheme" }, Xml = "<categories fixed='yes' scheme='http://odata.org/scheme' xmlns='http://www.w3.org/2007/app'/>", ExpectedException = (ExpectedException)null }, // Categories with single category new { CategoriesMetadata = new AtomCategoriesMetadata() { Categories = new [] { new AtomCategoryMetadata { Term = "myterm", Scheme = "http://odata.org/scheme" } } }, Xml = "<categories xmlns='http://www.w3.org/2007/app'><atom:category term='myterm' scheme='http://odata.org/scheme' xmlns:atom='http://www.w3.org/2005/Atom'/></categories>", ExpectedException = (ExpectedException)null }, // Categories with two categories new { CategoriesMetadata = new AtomCategoriesMetadata() { Categories = new [] { new AtomCategoryMetadata { Term = "myterm", Scheme = "http://odata.org/scheme" }, new AtomCategoryMetadata { Term = "second", Scheme = "http://odata.org/scheme2" } } }, Xml = "<categories xmlns='http://www.w3.org/2007/app'>" + "<atom:category term='myterm' scheme='http://odata.org/scheme' xmlns:atom='http://www.w3.org/2005/Atom'/>" + "<atom:category term='second' scheme='http://odata.org/scheme2' xmlns:atom='http://www.w3.org/2005/Atom'/>" + "</categories>", ExpectedException = (ExpectedException)null }, // Categories with href and fixed (error) new { CategoriesMetadata = new AtomCategoriesMetadata() { Href = new Uri("http://odata.org/href"), Fixed = true }, Xml = string.Empty, ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomWriterMetadataUtils_CategoriesHrefWithOtherValues") }, // Categories with href and scheme (error) new { CategoriesMetadata = new AtomCategoriesMetadata() { Href = new Uri("http://odata.org/href"), Scheme = "http://odata.org/scheme" }, Xml = string.Empty, ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomWriterMetadataUtils_CategoriesHrefWithOtherValues") }, // Categories with href and non-empty categories (error) new { CategoriesMetadata = new AtomCategoriesMetadata() { Href = new Uri("http://odata.org/href"), Categories = new [] { new AtomCategoryMetadata() } }, Xml = string.Empty, ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomWriterMetadataUtils_CategoriesHrefWithOtherValues") }, }; var testDescriptors = testCases.Select(testCase => { ODataEntitySetInfo collection = new ODataEntitySetInfo { Url = new Uri("http://odata.org/url") }; AtomResourceCollectionMetadata metadata = new AtomResourceCollectionMetadata() { Categories = testCase.CategoriesMetadata }; collection.SetAnnotation(metadata); ODataServiceDocument serviceDocument = new ODataServiceDocument { EntitySets = new [] { collection } }; return new PayloadWriterTestDescriptor<ODataServiceDocument>( this.Settings, new [] { serviceDocument }, tc => { if (testCase.ExpectedException != null) { return new WriterTestExpectedResults(this.Settings.ExpectedResultSettings) { ExpectedException2 = testCase.ExpectedException }; } else { return new AtomWriterTestExpectedResults(this.Settings.ExpectedResultSettings) { Xml = testCase.Xml, FragmentExtractor = result => result .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingWorkspaceElementName) .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingCollectionElementName) .Element(TestAtomConstants.AtomPublishingXNamespace + TestAtomConstants.AtomPublishingCategoriesElementName) }; } }); }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.WriterTestConfigurationProvider.AtomFormatConfigurations.Where(tc => !tc.IsRequest), (testDescriptor, testConfiguration) => { testConfiguration = testConfiguration.Clone(); testConfiguration.MessageWriterSettings.SetServiceDocumentUri(ServiceDocumentUri); TestWriterUtils.WriteAndVerifyTopLevelContent( testDescriptor, testConfiguration, (messageWriter) => messageWriter.WriteServiceDocument(testDescriptor.PayloadItems.Single()), this.Assert, baselineLogger: this.Logger); }); }
/// <summary> /// Visits a serviceDocument. /// </summary> /// <param name="serviceDocument">The serviceDocument to visit.</param> protected virtual void VisitServiceDocument(ODataServiceDocument serviceDocument) { IEnumerable<ODataEntitySetInfo> collections = serviceDocument.EntitySets; if (collections != null) { foreach (ODataEntitySetInfo collection in collections) { this.Visit(collection); } } }
/// <summary> /// Generate a default ODataServiceDocument instance from model. /// </summary> /// <param name="model">The Edm Model frm which to generate the service document.</param> /// <returns>The generated service document.</returns> public static ODataServiceDocument GenerateServiceDocument(this IEdmModel model) { ExceptionUtils.CheckArgumentNotNull(model, "model"); if (model.EntityContainer == null) { throw new ODataException(Strings.ODataUtils_ModelDoesNotHaveContainer); } ODataServiceDocument serviceDocument = new ODataServiceDocument(); serviceDocument.EntitySets = model.EntityContainer.EntitySets() .Select(entitySet => new ODataEntitySetInfo() { Name = entitySet.Name, Title = entitySet.Name, Url = new Uri(entitySet.Name, UriKind.RelativeOrAbsolute) }).ToList(); serviceDocument.Singletons = model.EntityContainer.Singletons() .Select(singleton => new ODataSingletonInfo() { Name = singleton.Name, Title = singleton.Name, Url = new Uri(singleton.Name, UriKind.RelativeOrAbsolute) }).ToList(); serviceDocument.FunctionImports = model.EntityContainer.OperationImports().OfType<IEdmFunctionImport>().Where(functionImport => functionImport.IncludeInServiceDocument) .Select(functionImport => new ODataFunctionImportInfo() { Name = functionImport.Name, Title = functionImport.Name, Url = new Uri(functionImport.Name, UriKind.RelativeOrAbsolute) }).ToList(); return serviceDocument; }
public void ShouldWriteServiceDocumentAsyncWithoutModel() { ODataServiceDocument serviceDocument = new ODataServiceDocument(); serviceDocument.EntitySets = new ODataEntitySetInfo[] { new ODataEntitySetInfo { Name = "Customers", Url = new Uri("http://host/Customers") } }; WriteAndValidate(outputContext => outputContext.WriteServiceDocumentAsync(serviceDocument).Wait(), "{\"@odata.context\":\"http://odata.org/test/$metadata\",\"value\":[{\"name\":\"Customers\",\"kind\":\"EntitySet\",\"url\":\"http://host/Customers\"}]}", writingResponse: true, synchronous: false); }
public void WriteNullFunctionImportShouldThrow() { var functionImports = new List<ODataFunctionImportInfo>(); functionImports.Add(null); var serviceDocument = new ODataServiceDocument() { FunctionImports = functionImports }; //Note: Only testing one of three exceptions that occurs in the Validate ServiceDocumentElements because if one throws then we know that the code path is going through // the validation method. If the validation method is changed then in the future two exception tests might be needed. WriteServiceDocumentShouldError(serviceDocument).ShouldThrow<ODataException>().WithMessage(Strings.ValidationUtils_WorkspaceResourceMustNotContainNullItem); }
private void TestEntitySetInServiceDocument(ODataServiceDocument serviceDocument) { serviceDocument.EntitySets.Should().NotBeNull(); var entitySets = serviceDocument.EntitySets.ToList(); entitySets.Count.Should().Be(1); entitySets[0].Name.Should().Be("entityset"); entitySets[0].Url.ToString().Should().Be("http://service/entityset"); }