public void Retrieve_PerformsCorrectRequest() { //Setup var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); //Mock crap var response = new RestResponse <BlankApplication> { Data = new BlankApplication() }; var restReq = new Mock <IRestRequest>(); restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey")); restReq.Setup(x => x.AddParameter("JobDID", "JXXXXXXXXXXXXXXXXXX")); restReq.SetupSet(x => x.RootElement = "BlankApplication"); var restClient = new Mock <IRestClient>(); restClient.SetupSet(x => x.BaseUrl = "https://api.careerbuilder.com/v1/application/blank"); restClient.Setup(x => x.Execute <BlankApplication>(It.IsAny <IRestRequest>())).Returns(response); request.Request = restReq.Object; request.Client = restClient.Object; //Assert BlankApplication resp = request.Retrieve(); restReq.VerifyAll(); restClient.VerifyAll(); }
public void Retrieve_PerformsCorrectRequest() { //Setup var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); //Mock crap var response = new RestResponse<BlankApplication> {Data = new BlankApplication()}; var restReq = new Mock<IRestRequest>(); restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey")); restReq.Setup(x => x.AddParameter("JobDID", "JXXXXXXXXXXXXXXXXXX")); restReq.SetupSet(x => x.RootElement = "BlankApplication"); var restClient = new Mock<IRestClient>(); restClient.SetupSet(x => x.BaseUrl = "https://api.careerbuilder.com/v1/application/blank"); restClient.Setup(x => x.Execute<BlankApplication>(It.IsAny<IRestRequest>())).Returns(response); request.Request = restReq.Object; request.Client = restClient.Object; //Assert BlankApplication resp = request.Retrieve(); restReq.VerifyAll(); restClient.VerifyAll(); }
public void Retrieve_AddsProperHeaders() { //Setup var site = new TargetSiteMock("10.0.0.1") { SetHost = "api.koolkid.com", SetSecure = true }; site.SetHeaders.Add("ILikeHeaders", "true"); var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "",site); //Mock crap var response = new RestResponse<BlankApplication> {Data = new BlankApplication()}; var restReq = new Mock<IRestRequest>(); restReq.Setup(x => x.AddHeader("Host", "api.koolkid.com")); restReq.Setup(x => x.AddHeader("ILikeHeaders", "true")); restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey")); restReq.Setup(x => x.AddParameter("JobDID", "JXXXXXXXXXXXXXXXXXX")); restReq.SetupSet(x => x.RootElement = "BlankApplication"); var restClient = new Mock<IRestClient>(); restClient.SetupSet(x => x.BaseUrl = "https://10.0.0.1/v1/application/blank"); restClient.Setup(x => x.Execute<BlankApplication>(It.IsAny<IRestRequest>())).Returns(response); request.Request = restReq.Object; request.Client = restClient.Object; //Assert BlankApplication resp = request.Retrieve(); restReq.VerifyAll(); restClient.VerifyAll(); }
public void GetRequestURL_BuildsCorrectEndpointAddress() { var site = new TargetSiteMock("10.0.0.1") { SetHost = "api.koolkid.com", SetSecure = true }; var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "", "", site); Assert.AreEqual("https://10.0.0.1/v1/application/blank", request.RequestURL); }
public void Constructor_ThrowsException_WhenPassedBadJobDID() { try { var request = new BlankAppStub("UXXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); Assert.Fail("Should have thrown exception"); } catch (ArgumentException ex) { Assert.IsInstanceOfType(ex, typeof (ArgumentException)); } try { var request = new BlankAppStub("JXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); Assert.Fail("Should have thrown exception"); } catch (ArgumentException ex) { Assert.IsInstanceOfType(ex, typeof (ArgumentException)); } }
public void Constructor_ThrowsException_WhenPassedBadJobDID() { try { var request = new BlankAppStub("UXXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); Assert.Fail("Should have thrown exception"); } catch (ArgumentException ex) { Assert.IsInstanceOf <ArgumentException>(ex); } try { var request = new BlankAppStub("JXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); Assert.Fail("Should have thrown exception"); } catch (ArgumentException ex) { Assert.IsInstanceOf <ArgumentException>(ex); } }
public void Retrieve_AddsProperHeaders() { //Setup var site = new TargetSiteMock("10.0.0.1") { SetHost = "api.koolkid.com", SetSecure = true }; site.SetHeaders.Add("ILikeHeaders", "true"); var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", site); //Mock crap var response = new RestResponse <BlankApplication> { Data = new BlankApplication() }; var restReq = new Mock <IRestRequest>(); restReq.Setup(x => x.AddHeader("Host", "api.koolkid.com")); restReq.Setup(x => x.AddHeader("ILikeHeaders", "true")); restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey")); restReq.Setup(x => x.AddParameter("JobDID", "JXXXXXXXXXXXXXXXXXX")); restReq.SetupSet(x => x.RootElement = "BlankApplication"); var restClient = new Mock <IRestClient>(); restClient.SetupSet(x => x.BaseUrl = "https://10.0.0.1/v1/application/blank"); restClient.Setup(x => x.Execute <BlankApplication>(It.IsAny <IRestRequest>())).Returns(response); request.Request = restReq.Object; request.Client = restClient.Object; //Assert BlankApplication resp = request.Retrieve(); restReq.VerifyAll(); restClient.VerifyAll(); }
public void Constructor_ThrowsException_WhenPassedNullOrEmpty() { try { var request = new BlankAppStub(null, "DevKey", "api.careerbuilder.com", "", ""); Assert.Fail("Should have thrown exception"); } catch (ArgumentNullException ex) { Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); } try { var request = new BlankAppStub("", "DevKey", "api.careerbuilder.com", "", ""); Assert.Fail("Should have thrown exception"); } catch (ArgumentNullException ex) { Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); } }
public void GetRequestURL_BuildsCorrectEndpointAddress() { var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); Assert.AreEqual("https://api.careerbuilder.com/v1/application/blank", request.RequestURL); }
public void Constructor_SetsJobDID() { var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey", "api.careerbuilder.com", "", ""); Assert.AreEqual("JXXXXXXXXXXXXXXXXXX", request.JobDID); }
public void GetRequestURL_BuildsCorrectEndpointAddress() { var site = new TargetSiteMock("10.0.0.1") { SetHost = "api.koolkid.com", SetSecure = true }; var request = new BlankAppStub("JXXXXXXXXXXXXXXXXXX", "DevKey","","",site); Assert.AreEqual("https://10.0.0.1/v1/application/blank", request.RequestURL); }