private async static Task <Configurations> LoadConfigurationsAsync() { ConfigurationsLoader configurationsLoader = new ConfigurationsLoader(); using (var streamReader = new StreamReader(_configurationFileName)) { return(await configurationsLoader.LoadAsync(streamReader)); } }
public async Task GivenNotExistingFile_Load_ConfigurationsLoadingExceptionThrown() { var mockedStreamReader = new Mock <TextReader>(); mockedStreamReader.Setup(s => s.ReadToEndAsync()).ThrowsAsync(new FileNotFoundException("File not found.")); var configurationsLoader = new ConfigurationsLoader(); Configurations configurations = await configurationsLoader.LoadAsync(mockedStreamReader.Object); }
public async Task GivenInvalidJson_Load_ConfigurationsLoadingExceptionThrown() { const string expectedConfigurationJsonified = "{\"test\": \"test\"}"; var mockedStreamReader = new Mock <TextReader>(); mockedStreamReader.Setup(s => s.ReadToEndAsync()).ReturnsAsync(expectedConfigurationJsonified); var configurationsLoader = new ConfigurationsLoader(); Configurations configurations = await configurationsLoader.LoadAsync(mockedStreamReader.Object); }
public async Task GivenValidFileWithUnusedParameters_Load_ValidConfigurationReturned() { var expected = new Configurations(_expectedUri); const string expectedConfigurationJsonified = "{\"redditApiEndpoint\": \"https://tdd.reddit.com/api/\",\"test\": \"test\"}"; var mockedStreamReader = new Mock <TextReader>(); mockedStreamReader.Setup(s => s.ReadToEndAsync()).ReturnsAsync(expectedConfigurationJsonified); var configurationsLoader = new ConfigurationsLoader(); Configurations actual = await configurationsLoader.LoadAsync(mockedStreamReader.Object); Assert.AreEqual(expected, actual); }