December 2019
Intermediate to advanced
598 pages
12h 21m
English
Follow these steps to implement a couple of tests on the GetQuestion method:
[Fact]public async void GetQuestion_WhenQuestionNotFound_Returns404(){ var mockDataRepository = new Mock<IDataRepository>(); mockDataRepository .Setup(repo => repo.GetQuestion(1)) .Returns(() => Task.FromResult(default(QuestionGetSingleResponse))); var mockQuestionCache = new Mock<IQuestionCache>(); mockQuestionCache .Setup(cache => cache.Get(1)) .Returns(() => null); var mockConfigurationRoot = new Mock<IConfigurationRoot>(); mockConfigurationRoot.SetupGet(config => config[It.IsAny<string>()]).Returns("some ...Read now
Unlock full access