public void CandidateRepository_CreateCandidate_ShouldCreateCandidate()
        {
            //-- Arrange
            var languages = new List <string>()
            {
                "c#", "lua"
            };

            var candidate = new Candidate()
            {
                FirstName      = "Jim J",
                LastName       = "Poggers",
                YearsCoding    = 3,
                Languages      = languages,
                ExpectedSalary = 65000
            };

            //-- act
            _repo.CreateCandidate(candidate);
            var expected = 1;
            var actual   = _repo.Getlist().Count;

            //-- assert
            Assert.AreEqual(expected, actual);
        }
Example #2
0
        // POST api/Candidate
        public HttpResponseMessage Post(string databaseId, NewCandidate value)
        {
            try
            {
                CandidateRepository candidateRepository;
                candidateRepository = new CandidateRepository(databaseId);
                string message = string.Empty;

                if (!candidateRepository.IsValidCandidate(value, out message))
                {
                    var dataErrorResponse = Request.CreateErrorResponse(System.Net.HttpStatusCode.BadRequest, message);

                    return(dataErrorResponse);
                }

                Candidate result = candidateRepository.CreateCandidate(value);

                var response = Request.CreateResponse <Candidate>(System.Net.HttpStatusCode.Created, result);
                return(response);
            }
            catch (Exception ex)
            {
                var response = Request.CreateErrorResponse(System.Net.HttpStatusCode.InternalServerError, ex);
                return(response);
            }
        }