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

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

            var retval = _labelManager.GetLabelByIdAsync(id);

            Assert.IsNull(retval.Result);
        }
        public async Task <IActionResult> GetLabelByIdAsync(string id)
        {
            logger.LogInformation($"GetLabel id: {id} - Resource Requested.");


            if (validation.ValidateId(id))
            {
                var label = await labelManager.GetLabelByIdAsync(id);

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

            return(NotFound());
        }