public async Task GetContentById_ReturnsOk() { // Arrange var expectedContentId = 0xdead; var expectedTitle = "EXPECTED TITLE"; var expectedContentDto = new Models.Dto.Content { Title = expectedTitle }; var cacheKey1 = $"{nameof(ContentController)}_{expectedContentId}"; var expectedModel = new Shared.Content(expectedContentId, string.Empty, string.Empty, string.Empty, string.Empty, new string[0]); object junk; The <IMemoryCache>().Setup(m => m.TryGetValue(cacheKey1, out junk)).Returns(false); The <IMemoryCache>().Setup(m => m.CreateEntry(It.IsAny <string>())).Returns(The <ICacheEntry>().Object); The <IContentRepository>() .Setup(m => m.GetAsync(expectedContentId, It.IsAny <CancellationToken>())) .ReturnsAsync(expectedContentDto); The <IMapper>() .Setup(m => m.Map <Shared.Content>(expectedContentDto)) .Returns(expectedModel); // Act var response = await Target.GetContentById(expectedContentId); // Assert Assert.Same(expectedModel, response.Value); VerifyAll(); }