public void Load_Should_Throw_Exception_On_Not_Existing_File() { var tempFile = GetTemporaryFile(); var repository = new CatDataRepository(new Settings(tempFile)); Assert.ThrowsAsync <FileNotFoundException>(() => repository.LoadAsync()); }
public void Load_Should_Throw_Exception_On_Bad_Data() { var tempFile = GetTemporaryFile(); var repository = new CatDataRepository(new Settings(tempFile)); File.WriteAllText(tempFile, "Non-JSON gibberish"); Assert.ThrowsAsync <JsonReaderException>(() => repository.LoadAsync()); }
public async Task Load_Should_Cat_Data() { var tempFile = GetTemporaryFile(); var repository = new CatDataRepository(new Settings(tempFile)); File.WriteAllText(tempFile, JsonConvert.SerializeObject(Cats)); var cats = await repository.LoadAsync(); cats.Count().Should().BeGreaterThan(0); File.Delete(tempFile); }
public void Load_Should_Throw_General_Exception() { Assert.ThrowsAsync <ArgumentNullException>(() => CatDataRepository.LoadAsync()); }