public void FormattingADisputeAsHal_WithACallToGetALinkForTheParentDisputeCollectionInTheConfiguration_CallsGetLink() { // Arrange const int disputeId = 12345; var mockedAddressResolver = new Mock <IAddressResolver>(); var responseObject = new DisputeResponse(mockedAddressResolver.Object); var expectedDispute = new DisputeModel { DisputeId = disputeId }; // Act responseObject.FormatForHal(expectedDispute); // Assert mockedAddressResolver.Verify( mock => mock.GetLink(DomainResources.Disputes, CommonLinks.Parent), Times.Once); }
public void FormattingADisputeAsHal_WithAValidDispute_ShouldSetEmbeddedLinks() { // Arrange var expectedLinks = new List <Link> { // new Link(DomainResources.Dispute, CommonLinks.Self), new Link(DomainResources.Disputes, CommonLinks.Parent) }; var expectedDispute = TestHelpers.CreateDispute(); var mockedAddressResolver = new Mock <IAddressResolver>(); mockedAddressResolver.Setup(s => s.GetLink(It.IsAny <string>(), It.IsAny <string>())) .Returns((string routeName, string linkName) => new Link(routeName, linkName)); var responseObject = new DisputeResponse(mockedAddressResolver.Object); // Act var halFormattedResponse = responseObject.FormatForHal(expectedDispute); // Assert halFormattedResponse.ShouldHaveLinks(expectedLinks); }