public void Create_WithRouteNameNull_Throws_ArgumentNullException(string rel) { // arrange ActionDescriptorCollectionProviderArrangements(rel); var sut = new ResourceLinkFactory(_mockUrlHelper.Object, _mockActionDescriptorCollectionProvider.Object); const string parameterName = "rel"; // act Action actual = () => sut.Create(rel, It.IsAny <IDictionary <string, object> >()); // assert Assert.Throws <ArgumentNullException>(parameterName, actual); }
public void Create_WithRouteNotFound_Throws_NotSupportedException() { // arrange const string existentRouteName = "exists"; const string notExistentRouteName = "notExists"; ActionDescriptorCollectionProviderArrangements(existentRouteName); var sut = new ResourceLinkFactory(_mockUrlHelper.Object, _mockActionDescriptorCollectionProvider.Object); // act Action actual = () => sut.Create(notExistentRouteName, It.IsAny <IDictionary <string, object> >()); // assert Assert.Throws <NotSupportedException>(actual); }
public void Create_ValidParameters_ReturnsResourceLink(object data, string routeName, string url, string method) { // arrange ActionDescriptorCollectionProviderArrangements(routeName, method); var routeDictionary = data?.ToRouteDictionary(); // can be null _mockUrlHelper.Setup(x => x.Link(routeName, routeDictionary)).Returns(url); var sut = new ResourceLinkFactory(_mockUrlHelper.Object, _mockActionDescriptorCollectionProvider.Object); // act var resourceLink = sut.Create(routeName, routeDictionary); // assert Assert.IsType <ResourceLink>(resourceLink); Assert.NotNull(resourceLink); Assert.Equal(url, resourceLink.Href); Assert.Equal(routeName, resourceLink.Rel); Assert.Equal(method, resourceLink.Method); }