public void GetSubscription_ReturnsSubscriptionForUser_WhenValidUserId()
        {
            // arrange
            _subscriptionRepositoryMock.Setup(x => x.GetSubscriptionBySubscriptionId(It.IsAny <int>())).Returns(MockData.Subscriptions.GetValidSubscription());
            _userServiceMock.Setup(x => x.GetUserByUsername(It.IsAny <string>())).Returns(MockData.Users.GetValidUser());

            // act
            var result = _subscriptionService.AddUserSubscription(1);

            // assert
            Assert.NotNull(result);
        }
Example #2
0
        public async Task <IActionResult> Post([FromBody] SubscriptionRequest request)
        {
            var result = await _subscriptionService.AddUserSubscription(request.UserId);

            if (!result)
            {
                return(BadRequest(result));
            }
            return(Created("subscription", result));
        }