public void GetRandomNameWorksAgainstLiveApi() { var feed = new RandomNameJsonFeed(); var name = feed.GetRandomFullName(); Assert.IsNotNull(name, "Returned name was null."); // Since we don't know what the live server will return, just do a very simple test. StringAssert.IsMatch(@"^(\w*) (\w*)$", name, "Valid name was not returned"); }
public void GetRandomNameWorksHandlesValidResponse() { const string firstName = "Grace"; const string surName = "Hopper"; var handlerMock = CreateMessageHandlerMock(HttpStatusCode.OK, MakeJson(firstName, surName, "female", "USA"), ExpectedUri); var feed = new RandomNameJsonFeed(handlerMock.Object); var name = feed.GetRandomFullName(); Assert.AreEqual($"{firstName} {surName}", name, "Name was wrong."); }