public async Task GetQuestions_ShouldThrowException_WhenInvalidData(string json) { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(true); fileRepository.Setup(_ => _.ReadFile(It.IsAny <string>())).Returns(json); var adventureService = new AdventureService(fileRepository.Object, logger.Object); await Assert.ThrowsAsync <InvalidDataException>(() => adventureService.GetQuestionsAsync("testName")); }
public async Task GetQuestions_ShouldReturnAllQuestion(string json, int count) { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(true); fileRepository.Setup(_ => _.ReadFile(It.IsAny <string>())).Returns(json); var adventureService = new AdventureService(fileRepository.Object, logger.Object); var questions = await adventureService.GetQuestionsAsync("testName"); Assert.NotNull(questions); Assert.Equal(questions.Count(), count); }
public async Task GetQuestions_ShouldThrowException_WhenInvalidPath() { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(false); var adventureService = new AdventureService(fileRepository.Object, logger.Object); await Assert.ThrowsAsync <FileNotFoundException>(() => adventureService.GetQuestionsAsync("testName")); }