Beispiel #1
0
        public async Task GetRelationshipsAsync_Throws_405_If_No_Service()
        {
            // arrange
            const int id          = 0;
            var       serviceMock = new Mock <IGetRelationshipsService <Resource> >();
            var       controller  = new BaseJsonApiController <Resource>(_jsonApiContextMock.Object, getRelationships: null);

            // act
            var exception = await Assert.ThrowsAsync <JsonApiException>(() => controller.GetRelationshipsAsync(id, string.Empty));

            // assert
            Assert.Equal(405, exception.GetStatusCode());
        }
Beispiel #2
0
        public async Task GetRelationshipsAsync_Calls_Service()
        {
            // Arrange
            const int id          = 0;
            var       serviceMock = new Mock <IGetRelationshipsService <Resource> >();
            var       controller  = new BaseJsonApiController <Resource>(new Mock <IJsonApiOptions>().Object, getRelationships: serviceMock.Object);

            // Act
            await controller.GetRelationshipsAsync(id, string.Empty);

            // Assert
            serviceMock.Verify(m => m.GetRelationshipsAsync(id, string.Empty), Times.Once);
        }