public void NormalizesNavigationLinksWhenSet(string requestUri) { // Arrange var v2FeedPackage = new V2FeedPackage() { Id = "SomePackageId", Version = "1.0.0", Title = "Title", Authors = ".NET Foundation", LastUpdated = DateTime.UtcNow, Summary = "Summary" }; var annotationStrategy = new V2FeedPackageAnnotationStrategy(_contentType); var oDataEntry = new ODataEntry(); var dummyIdLink = new Uri("https://localhost"); oDataEntry.Id = dummyIdLink.ToString(); oDataEntry.EditLink = dummyIdLink; oDataEntry.ReadLink = dummyIdLink; var request = CreateHttpRequestMessage(requestUri); var expectedNormalizedLink = "https://localhost/api/v2/Packages(Id='SomePackageId',Version='1.0.0')"; // Act annotationStrategy.Annotate(request, oDataEntry, v2FeedPackage); // Assert Assert.Equal(expectedNormalizedLink, oDataEntry.ReadLink.ToString()); Assert.Equal(expectedNormalizedLink, oDataEntry.EditLink.ToString()); Assert.Equal(expectedNormalizedLink, oDataEntry.Id.ToString()); }
public void CanNotAnnotateNullObject() { // Arrange var annotationStrategy = new V2FeedPackageAnnotationStrategy(_contentType); // Act var canAnnotate = annotationStrategy.CanAnnotate(null); // Assert Assert.False(canAnnotate); }
public void CanNotAnnotateV1FeedPackage() { // Arrange var v1FeedPackage = new V1FeedPackage(); var annotationStrategy = new V2FeedPackageAnnotationStrategy(_contentType); // Act var canAnnotate = annotationStrategy.CanAnnotate(v1FeedPackage); // Assert Assert.False(canAnnotate); }
public void SetsMediaResourceAnnotation() { // Arrange var v2FeedPackage = new V2FeedPackage() { Id = "SomePackageId", Version = "1.0.0", Title = "Title", Authors = ".NET Foundation", LastUpdated = DateTime.UtcNow, Summary = "Summary" }; var annotationStrategy = new V2FeedPackageAnnotationStrategy(_contentType); var oDataEntry = new ODataEntry(); var request = CreateHttpRequestMessage("https://localhost/api/v2/Packages"); // Act annotationStrategy.Annotate(request, oDataEntry, v2FeedPackage); // Assert Assert.Equal(_contentType, oDataEntry.MediaResource.ContentType); Assert.Equal("https://localhost/api/v2/package/SomePackageId/1.0.0", oDataEntry.MediaResource.ReadLink.ToString()); }
public void SetsAtomEntryMetadataAnnotation() { // Arrange var v2FeedPackage = new V2FeedPackage() { Id = "SomePackageId", Version = "1.0.0", Title = "Title", Authors = ".NET Foundation", LastUpdated = DateTime.UtcNow, Summary = "Summary" }; var annotationStrategy = new V2FeedPackageAnnotationStrategy(_contentType); var oDataEntry = new ODataEntry(); var request = CreateHttpRequestMessage("https://localhost/api/v2/Packages"); var expectedAtomEntryMetadataAnnotation = new AtomEntryMetadata() { Title = v2FeedPackage.Id, Authors = new[] { new AtomPersonMetadata { Name = v2FeedPackage.Authors } }, Updated = v2FeedPackage.LastUpdated, Summary = v2FeedPackage.Summary }; // Act annotationStrategy.Annotate(request, oDataEntry, v2FeedPackage); 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); }