public void BaseURL_IsNotSecure_WhenTargetSiteIsntSecure() { //Setup var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com", SetSecure=false }; var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite }; var request = new GetRequestStub(settings); Assert.AreEqual("http://127.0.0.1/Exammple", request.GetRequestURL); }
public void Constructor_ThrowsException_OnNullDomain() { try { var request = new GetRequestStub("DevKey", null, "", ""); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); } }
public void Constructor_ThrowsException_OnNullDevKey() { try { var request = new GetRequestStub(null, "api.careerbuilder.com", "", ""); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); } }
public void BeforeRequest_AddsHostParameter() { //Setup var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com" }; var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite }; var request = new GetRequestStub(settings); //Mock crap var restReq = new Mock<IRestRequest>(); restReq.Setup(x => x.AddHeader("Host", "www.google.com")); var restClient = new Mock<IRestClient>(); request.Request = restReq.Object; request.Client = restClient.Object; //Assert request.RunBeforeGet(); restReq.VerifyAll(); }
public void BeforeRequest_SetsDevKey_AndDomain_AndCobrand_AndSiteID_AndTimeout() { //Setup var request = new GetRequestStub(_Settings); //Mock crap var restReq = new Mock<IRestRequest>(); restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey")); restReq.Setup(x => x.AddParameter("CoBrand", "this is a cobrand")); restReq.Setup(x => x.AddParameter("SiteID", "this is a siteid")); restReq.SetupSet(x => x.Timeout = 12345); var restClient = new Mock<IRestClient>(); request.Request = restReq.Object; request.Client = restClient.Object; //Assert request.RunBeforeGet(); restReq.VerifyAll(); }
public void Constructor_SetsSiteID() { var request = new GetRequestStub("DevKey", "api.careerbuilder.com", "", "SiteID"); Assert.AreEqual("SiteID", request.SiteID); }
public void Constructor_SetsCobrand() { var request = new GetRequestStub("DevKey", "api.careerbuilder.com", "cobrandcode", ""); Assert.AreEqual("cobrandcode", request.CobrandCode); }
public void Constructor_SetsDomain() { var request = new GetRequestStub("DevKey", "api.careerbuilder.com", "", ""); Assert.AreEqual("api.careerbuilder.com", request.Domain); }
public void BeforeRequest_RaisesBeforeRequestEvent() { //Setup var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com" }; var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite }; var request = new GetRequestStub(settings); //Mock crap var restReq = new Mock<IRestRequest>(); var restClient = new Mock<IRestClient>(); restClient.Setup(x => x.BaseUrl).Returns("https://127.0.0.1/Exammple"); request.Request = restReq.Object; request.Client = restClient.Object; //Assert request.OnBeforeRequest += (HandleBeforeRequest); request.RunBeforeGet(); Assert.AreEqual(true, _HasEventFired); request.OnBeforeRequest -= (HandleBeforeRequest); }