public async Task GetAdventures_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.GetAdventuresAsync()); }
public async Task GetAdventures_ShouldReturnAllAdventures(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 adventures = await adventureService.GetAdventuresAsync(); Assert.NotNull(adventures); Assert.Equal(adventures.Count(), count); }
public async Task GetAdventures_ShouldThrowException_WhenInvalidPath() { fileRepository.Setup(_ => _.IsFileExist(It.IsAny <string>())).Returns(false); var adventureService = new AdventureService(fileRepository.Object, logger.Object); await Assert.ThrowsAsync <FileNotFoundException>(() => adventureService.GetAdventuresAsync()); }