Example #1
0
        public void GetArtistByIdAsync_Given_NoArtist_Should_Return_Null()
        {
            mongoDBPersistance
            .Setup(s => s.FindArtistByIdAsync(It.IsAny <Guid>()))
            .Returns(Task.FromResult((Artist)null));

            string id = "123e4567-e89b-12d3-a456-426652340000";

            var retval = _artistManager.GetArtistByIdAsync(id);

            Assert.IsNull(retval.Result);
        }
        // [Authorize]
        public async Task <IActionResult> GetArtistByIdAsync(string id)
        {
            logger.LogInformation($"GetArtist id: {id} - Resource Requested.");

            var validateId = validation.ValidateId(id);


            if (validateId.resultValid)
            {
                var artist = await artistManager.GetArtistByIdAsync(id);

                if (artist != null)
                {
                    return(Ok(artist));
                }

                return(NotFound());
            }

            return(BadRequest(validateId.message));
        }