public void Search_PerformsCorrectRequest()
        {
            //Setup
            var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");

            //Mock crap
            var response = new RestResponse<ResponseJobSearch> {Data = new ResponseJobSearch()};

            var restReq = new Mock<IRestRequest>();
            restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey"));
            restReq.Setup(x => x.AddParameter("CountryCode", "NL"));
            restReq.SetupSet(x => x.RootElement = "ResponseJobSearch");

            var restClient = new Mock<IRestClient>();
            restClient.SetupSet(x => x.BaseUrl = "https://api.careerbuilder.com/v1/jobsearch");
            restClient.Setup(x => x.Execute<ResponseJobSearch>(It.IsAny<IRestRequest>())).Returns(response);

            request.Request = restReq.Object;
            request.Client = restClient.Object;

            //Assert
            ResponseJobSearch resp = request.WhereCountryCode(CountryCode.NL).Search();
            restReq.Verify();
            restClient.VerifyAll();
        }
 public void WhereNotCompanyName_SetsCorrectParameter() {
     var jobSearch = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     jobSearch.WhereNotCompanyName("Coca Cola");
     jobSearch.AddParametersToRequest();
     var param = jobSearch.Request.Parameters.Find(qs => qs.Name == "ExcludeCompanyNames");
     Assert.IsNotNull(param, "ExcludeCompanyNames should exist.");
     Assert.AreEqual("Coca Cola", param.Value, "ExcludeCompanyNames value should be 'Coca Cola'");
 }
        public void WhereClause_AddsToOutgoingParams() {
            //Setup
            var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");

            //Mock crap
            var response = new RestResponse<ResponseJobSearch> { Data = new ResponseJobSearch() };

            var restReq = new Mock<IRestRequest>();
            restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey"));
            restReq.Setup(x => x.AddParameter("silly", "value"));
            restReq.SetupSet(x => x.RootElement = "ResponseJobSearch");

            var restClient = new Mock<IRestClient>();
            restClient.SetupSet(x => x.BaseUrl = "https://api.careerbuilder.com/v1/jobsearch");
            restClient.Setup(x => x.Execute<ResponseJobSearch>(It.IsAny<IRestRequest>())).Returns(response);

            request.Request = restReq.Object;
            request.Client = restClient.Object;

            //Assert
            ResponseJobSearch resp = request.Where("Silly", "value").Search();
            restReq.Verify();
            restClient.VerifyAll();
        }
 public void WhereHostSite_SetsCountryCode()
 {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     request.WhereHostSite(HostSite.EU);
     Assert.AreEqual("EU", request.CountryCode);
 }
 public void WhereHostSite_ReturnsCategoryRequest()
 {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     Assert.IsInstanceOfType(request.WhereHostSite(HostSite.EU), typeof (IJobSearch));
 }
 public void WhereCountryCode_SetsCountryCode()
 {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     request.WhereCountryCode(CountryCode.SE);
     Assert.AreEqual("SE", request.CountryCode);
 }
 public void WhereCountryCode_ReturnsCategoryRequest()
 {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     Assert.IsInstanceOfType(request.WhereCountryCode(CountryCode.SE), typeof (IJobSearch));
 }
 public void GetRequestURL_BuildsCorrectEndpointAddress()
 {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     Assert.AreEqual("https://api.careerbuilder.com/v1/jobsearch", request.RequestURL);
 }
 public void Constructor_DefaultsToUSCountryCode()
 {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     Assert.AreEqual("US", request.CountryCode);
 }
 public void SetRecordsPerGroup_NotSet() {
     var jobSearch = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     jobSearch.AddParametersToRequest();
     var param_records_per_group = jobSearch.Request.Parameters.Find(qs => qs.Name == "recordspergroup");
     Assert.IsNull(param_records_per_group);
 }
 public void SetRecordsPerGroup() {
     var jobSearch = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     jobSearch.SetRecordsPerGroup(2); 
     jobSearch.AddParametersToRequest();
     var param_records_per_group = jobSearch.Request.Parameters.Find(qs => qs.Name == "recordspergroup").Value;
     Assert.AreEqual(2,param_records_per_group );
 }
 public void WhereGroupValue_SetsCorrectParameters_WhenNotSet() {
     var jobSearch = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     jobSearch.AddParametersToRequest();
     var param_grouping_value = jobSearch.Request.Parameters.Find(qs => qs.Name == "groupingvalue");
     var param_advanced_grouping = jobSearch.Request.Parameters.Find(qs => qs.Name == "advancedgroupingmode").Value;
     var param_enable_company_job_title_collapse = jobSearch.Request.Parameters.Find(qs => qs.Name == "enablecompanyjobtitlecollapse").Value;
     Assert.IsNull(param_grouping_value);
     Assert.AreEqual(false,param_advanced_grouping);
     Assert.AreEqual(false,param_enable_company_job_title_collapse);
 }
 public void WhereNotKeywords_SetsCorrectParameter_Empty() {
     var jobSearch = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     jobSearch.WhereNotKeywords(" ");
     jobSearch.AddParametersToRequest();
     var param = jobSearch.Request.Parameters.Find(qs => qs.Name == "excludekeywords");
     Assert.IsNull(param, "ExcludeKeywords should not exist.");
 }
 public void WhereNotKeywords_SetsCorrectParameter_Multiple() {
     var jobSearch = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     jobSearch.WhereNotKeywords("Coca Cola", "Intel Rabbit Co");
     jobSearch.AddParametersToRequest();
     var param = jobSearch.Request.Parameters.Find(qs => qs.Name == "excludekeywords");
     Assert.IsNotNull(param, "ExcludeKeywords should exist.");
     Assert.AreEqual("Coca Cola,Intel Rabbit Co", param.Value, "ExcludeKeywords value should be 'Coca Cola,Intel Rabbit Co'");
 }
 public void WhereHostSite_ReturnsCategoryRequest() {
     var request = new JobSearchStub("DevKey", "api.careerbuilder.com", "", "");
     Assert.IsInstanceOf<IJobSearch>(request.WhereHostSite("EU"));
 }