Example #1
0
        public async Task AddWish_ServiceMethodThrowsInvalidOperationException_ReturnsForbiddenStatusCodeWishMessage()
        {
            var exceptionMessage = "User cannot add his book to wish list";

            _wishListServiceMock.Setup(obj => obj.AddWishAsync(It.IsAny <int>()))
            .Throws(new InvalidOperationException(exceptionMessage));

            var result = await _controller.AddWish(It.IsAny <int>());

            var objectResult = result.Should().BeOfType <ObjectResult>().Subject;

            objectResult.StatusCode.Should().Be(403);
            objectResult.Value.Should().Be(exceptionMessage);
        }