Beispiel #1
0
        public void BuildReadLink_WhenReadLinkIsNotSameAsEditLink(bool followsConventions, object metadataLevel, bool linkEmitted)
        {
            _entitySet.HasReadLink(new SelfLinkBuilder <Uri>((context) => new Uri("http://readlink/"), followsConventions));
            EntitySetLinkBuilderAnnotation linkBuilder = new EntitySetLinkBuilderAnnotation(_entitySet);

            Uri generatedReadLink = linkBuilder.BuildReadLink(new EntityInstanceContext(), (ODataMetadataLevel)metadataLevel, new Uri("http://editLink"));

            if (linkEmitted)
            {
                Assert.Equal("http://readlink/", generatedReadLink.AbsoluteUri);
            }
            else
            {
                Assert.Null(generatedReadLink);
            }
        }
        public void HasReadLink(Func <EntityInstanceContext <TEntityType>, Uri> readLinkFactory, bool followsConventions)
        {
            if (readLinkFactory == null)
            {
                throw Error.ArgumentNull("readLinkFactory");
            }

            _configuration.HasReadLink(new SelfLinkBuilder <Uri>((entity) => readLinkFactory(UpCastEntityInstanceContext(entity)), followsConventions));
        }
        public void HasReadLink(Func <EntityInstanceContext <TEntityType>, Uri> readLinkFactory)
        {
            if (readLinkFactory == null)
            {
                throw Error.ArgumentNull("readLinkFactory");
            }

            _configuration.HasReadLink((entity) => readLinkFactory(UpCastEntityInstanceContext(entity)));
        }
Beispiel #4
0
        public void HasReadLink_RoundTrips()
        {
            // Arrange
            SelfLinkBuilder <Uri> readLinkBuilder = new SelfLinkBuilder <Uri>((ctxt) => null, followsConventions: true);

            // Act
            _entityset.HasReadLink(readLinkBuilder);

            // Assert
            Assert.Equal(readLinkBuilder, _entityset.GetReadLink());
        }