Inheritance: CBApi.Models.Service.TargetSite
        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 BaseURL_IsSecure_WhenTargetSiteIsSecure() {
     //Setup
     var newSite = new TargetSiteMock("127.0.0.1") { SetHost = "www.google.com", SetSecure = true };
     var settings = new APISettings() { DevKey = "DevKey", CobrandCode = "this is a cobrand", SiteId = "this is a siteid", TimeoutMS = 12345, TargetSite = newSite };
     var request = new PostRequestStub(settings);
     Assert.AreEqual("https://127.0.0.1/Exammple", request.GetRequestURL);
 }
        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_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 PostRequestStub(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 += (HandleAfterRequest);
            request.RunBeforeRequest();
            Assert.AreEqual(true, _HasEventFired);
            request.OnBeforeRequest -= (HandleAfterRequest);
        }
 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);
 }