Exemple #1
0
        public void GenerateODataLink_ThrowsIdLinkNullForEntityIdHeader_IfEntitySetLinkBuilderReturnsNull()
        {
            // Arrange
            var linkBuilder = new Mock <NavigationSourceLinkBuilderAnnotation>();
            var model       = new CustomersModelWithInheritance();

            model.Model.SetAnnotationValue(model.Customer, new ClrTypeAnnotation(typeof(TestEntity)));
            model.Model.SetNavigationSourceLinkBuilder(model.Customers, linkBuilder.Object);
            var path    = new ODataPath(new EntitySetSegment(model.Customers));
            var request = new HttpRequestMessage();

            request.ODataProperties().Path = path;
            request.EnableHttpDependencyInjectionSupport(model.Model);

            // Act & Assert
            Assert.Throws <InvalidOperationException>(
                () => ResultHelpers.GenerateODataLink(request, _entity, isEntityId: true),
                "The Id link builder for the entity set 'Customers' returned null. An Id link is required for the OData-EntityId header.");
        }
Exemple #2
0
 internal Uri GenerateLocationHeader()
 {
     return(ResultHelpers.GenerateODataLink(Request, Entity, isEntityId: false));
 }