public void WhenWordExistsExistenceRequestShouldReturnTrue() { var url = "https://www.dictionary.com/browse"; var word = "word-that-doesnt-exist"; var webRequestHelper = Substitute.For <IWebRequestHelper>(); webRequestHelper .Create($"{url}/{word}") .Returns(WebRequest.CreateDefault(new Uri($"{url}/{word}"))); var webDictionaryRequestHelper = new WebDictionaryRequestHelper(webRequestHelper); var response = webDictionaryRequestHelper.MakeExistenceRequest(word); response.Should().BeTrue(); }
public void WhenWordDoesNotExistExistenceRequestShouldReturnFalse() { var url = "https://www.dictionary.com/browse"; var word = "word-that-doesnt-exist"; var webRequestHelper = Substitute.For <IWebRequestHelper>(); webRequestHelper .Create($"{url}/{word}") .Throws(new Exception()); var webDictionaryRequestHelper = new WebDictionaryRequestHelper(webRequestHelper); var response = webDictionaryRequestHelper.MakeExistenceRequest(word); response.Should().BeFalse(); }