public void SendHeartbeat_WhenHeartbeatNameIsSet_VerifyCreate() { httpHandler .Setup(_ => _.CreateRequest(It.IsAny <string>())) .Returns((string url) => (HttpWebRequest)WebRequest.Create(url)); sut.SendHeartbeat(); httpHandler.Verify(_ => _.CreateRequest($"https://api.opsgenie.com/v2/heartbeats/{settings.HeartbeatName}/ping"), Times.Once); }
public void SendHeartbeat_WhenHeartbeatNameContainsIlligalCharacters_VerifyUrlEncodedCreate() { settings.HeartbeatName = "dummy&heartbeat%withillegal#chars"; sut = new OpsGenieApiClient(httpHandler.Object, settings); httpHandler .Setup(_ => _.CreateRequest(It.IsAny <string>())) .Returns((string url) => (HttpWebRequest)WebRequest.Create(url)); sut.SendHeartbeat(); httpHandler.Verify(_ => _.CreateRequest("https://api.opsgenie.com/v2/heartbeats/dummy%26heartbeat%25withillegal%23chars/ping"), Times.Once); }