public void ParseResult_EmptyJson_Throws() { SearchProvider search = new GoogleProvider(configuration); string json = string.Empty; Assert.Throws <ArgumentException>(() => search.ParseResponse(json)); }
public void ParseResult_ErrorJson_Throws() { SearchProvider search = new GoogleProvider(configuration); string json = "{ \"error\": { \"code\": 404, \"message\": \"Requested entity was not found.\", \"errors\": [ { \"message\": \"Requested entity was not found.\", \"domain\": \"global\", \"reason\": \"notFound\" } ], \"status\": \"NOT_FOUND\" }}"; Assert.Throws <ArgumentException>(() => search.ParseResponse(json)); }
public void ParseResult_CorrectJson_ReturnsTrue() { SearchProvider search = new GoogleProvider(configuration); string filename = "google.json"; Assembly thisAssembly = Assembly.GetExecutingAssembly(); var reader = new StreamReader(thisAssembly.GetManifestResourceStream(resourcesDir + filename)); string json = reader.ReadToEnd(); var response = search.ParseResponse(json); Assert.IsTrue(response.Any(r => r.Snippet.Contains("Bible", StringComparison.InvariantCultureIgnoreCase))); }