public async Task GetRelationshipAsync_Throws_405_If_No_Service() { // arrange const int id = 0; var serviceMock = new Mock <IGetRelationshipService <Resource> >(); var controller = new BaseJsonApiController <Resource>(_jsonApiContextMock.Object, getRelationship: null); // act var exception = await Assert.ThrowsAsync <JsonApiException>(() => controller.GetRelationshipAsync(id, string.Empty)); // assert Assert.Equal(405, exception.GetStatusCode()); }
public async Task GetRelationshipAsync_Calls_Service() { // Arrange const int id = 0; var serviceMock = new Mock <IGetRelationshipService <Resource> >(); var controller = new BaseJsonApiController <Resource>(new Mock <IJsonApiOptions>().Object, getRelationship: serviceMock.Object); // Act await controller.GetRelationshipAsync(id, string.Empty); // Assert serviceMock.Verify(m => m.GetRelationshipAsync(id, string.Empty), Times.Once); }