コード例 #1
0
 public void Constructor_ThrowsException_WhenPassedShortJobDID()
 {
     try
     {
         var request = new JobRequestStub("J12345678910", "DevKey", "api.careerbuilder.com", "", "");
         Assert.Fail();
     }
     catch (ArgumentException ex)
     {
         Assert.IsInstanceOf<ArgumentException>(ex);
     }
 }
コード例 #2
0
 public void Constructor_ThrowsException_WhenPassedBadJobDID()
 {
     try
     {
         var request = new JobRequestStub("W3T1SK6PN85V725Z6Q3", "DevKey", "api.careerbuilder.com", "", "");
         Assert.Fail();
     }
     catch (ArgumentException ex)
     {
         Assert.IsInstanceOf<ArgumentException>(ex);
     }
 }
コード例 #3
0
 public void Constructor_ThrowsException_WhenPassedNullJobDID()
 {
     try
     {
         var request = new JobRequestStub(null, "DevKey", "api.careerbuilder.com", "", "");
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.IsInstanceOfType(ex, typeof (ArgumentNullException));
     }
 }
コード例 #4
0
        public void Retrieve_PerformsCorrectRequest()
        {
            //Setup
            var request = new JobRequestStub("J3T1SK6PN85V725Z6Q3", "DevKey", "api.careerbuilder.com", "", "");

            //Mock crap
            var response = new RestResponse<Job> {Data = new Job {JobTitle = "Jeff's crazy job imporieum"}};

            var restReq = new Mock<IRestRequest>();
            restReq.Setup(x => x.AddParameter("DeveloperKey", "DevKey"));
            restReq.Setup(x => x.AddParameter("DID", "J3T1SK6PN85V725Z6Q3"));
            restReq.SetupSet(x => x.RootElement = "Job");

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

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

            //Assert
            Job myJob = request.Retrieve();
            Assert.AreSame(response.Data, myJob);
            restReq.VerifyAll();
            restClient.VerifyAll();
        }
コード例 #5
0
 public void Constructor_SetsJobDID()
 {
     try
     {
         var request = new JobRequestStub("J3T1SK6PN85V725Z6Q3", "DevKey", "api.careerbuilder.com", "", "");
         Assert.AreEqual("J3T1SK6PN85V725Z6Q3", request.JobDID);
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }