public void CanNotAnnotateNullObject()
        {
            // Arrange
            var annotationStrategy = new V1FeedPackageAnnotationStrategy(_contentType);

            // Act
            var canAnnotate = annotationStrategy.CanAnnotate(null);

            // Assert
            Assert.False(canAnnotate);
        }
        public void CanNotAnnotateV2FeedPackage()
        {
            // Arrange
            var v2FeedPackage      = new V2FeedPackage();
            var annotationStrategy = new V1FeedPackageAnnotationStrategy(_contentType);

            // Act
            var canAnnotate = annotationStrategy.CanAnnotate(v2FeedPackage);

            // Assert
            Assert.False(canAnnotate);
        }
        public void SetsMediaResourceAnnotation()
        {
            // Arrange
            var v1FeedPackage = new V1FeedPackage()
            {
                Id          = "SomePackageId",
                Version     = "1.0.0",
                Title       = "Title",
                Authors     = ".NET Foundation",
                LastUpdated = DateTime.UtcNow,
                Summary     = "Summary"
            };
            var annotationStrategy = new V1FeedPackageAnnotationStrategy(_contentType);
            var oDataEntry         = new ODataEntry();
            var request            = CreateHttpRequestMessage();

            // Act
            annotationStrategy.Annotate(request, oDataEntry, v1FeedPackage);

            // Assert
            Assert.Equal(_contentType, oDataEntry.MediaResource.ContentType);
            Assert.Equal("https://localhost/api/v1/package/SomePackageId/1.0.0", oDataEntry.MediaResource.ReadLink.ToString());
        }
        public void SetsAtomEntryMetadataAnnotation()
        {
            // Arrange
            var v1FeedPackage = new V1FeedPackage()
            {
                Id          = "SomePackageId",
                Version     = "1.0.0",
                Title       = "Title",
                Authors     = ".NET Foundation",
                LastUpdated = DateTime.UtcNow,
                Summary     = "Summary"
            };
            var annotationStrategy = new V1FeedPackageAnnotationStrategy(_contentType);
            var oDataEntry         = new ODataEntry();
            var request            = CreateHttpRequestMessage();

            var expectedAtomEntryMetadataAnnotation = new AtomEntryMetadata()
            {
                Title   = v1FeedPackage.Title,
                Authors = new[] { new AtomPersonMetadata {
                                      Name = v1FeedPackage.Authors
                                  } },
                Updated = v1FeedPackage.LastUpdated,
                Summary = v1FeedPackage.Summary
            };

            // Act
            annotationStrategy.Annotate(request, oDataEntry, v1FeedPackage);

            var actualAtomEntryMetadataAnnotation = oDataEntry.GetAnnotation <AtomEntryMetadata>();

            // Assert
            Assert.Equal(expectedAtomEntryMetadataAnnotation.Title.Text, actualAtomEntryMetadataAnnotation.Title.Text);
            Assert.Equal(expectedAtomEntryMetadataAnnotation.Summary.Text, actualAtomEntryMetadataAnnotation.Summary.Text);
            Assert.Equal(expectedAtomEntryMetadataAnnotation.Authors.Single().Name, actualAtomEntryMetadataAnnotation.Authors.Single().Name);
            Assert.Equal(expectedAtomEntryMetadataAnnotation.Updated, actualAtomEntryMetadataAnnotation.Updated);
        }