public void PutExecutesWithValidCandidateObject()
        {
            mockedCandidatedDataRepository.Setup(mock => mock.CreateCandidate(candidateObject));

            candidateController.Put(candidateObject);

            mockedCandidatedDataRepository.Verify(mock => mock.CreateCandidate(candidateObject));
        }
예제 #2
0
        public void ShouldAddRelocationPlaces()
        {
            var httpResult = controller.Get(1);
            var response   = httpResult as JsonResult <CandidateDTO>;
            var candidate  = response.Content;

            int countryId = context.Countries.First().Id;
            int cityId    = context.Cities.First().Id;

            var newRelocationPlace = new RelocationPlaceDTO
            {
                CountryId = countryId,
                CityId    = cityId
            };

            var places = candidate.RelocationPlaces.ToList();

            places.Add(newRelocationPlace);
            candidate.RelocationPlaces = places;

            var newHttpResult = controller.Put(candidate.Id, candidate);
            var newResponse   = newHttpResult as JsonResult <CandidateDTO>;
            var newCandidate  = newResponse.Content;

            Assert.IsTrue(newCandidate.RelocationPlaces.Any(x => x.CityId == cityId && x.CountryId == countryId));
        }
        public void PutSuccessfuly()
        {
            bool calledInsert = false;
            var  mockRep      = new Mock <ICandidateServices>();

            mockRep.Setup(x => x.Insert(candidateDetailViewModel)).Callback(() => calledInsert = true);
            CandidateController candidateController = new CandidateController(mockRep.Object);;

            candidateController.Put(candidateDetailViewModel);
            Assert.IsTrue(calledInsert);
        }
예제 #4
0
        public void PutReturnsContentResult()
        {
            // Arrange
            Candidate candidate = new Candidate
            {
                CandidateId = "123",
                FirstName   = "bob"
            };

            var mockRepository = new Mock <ICandidateRepository>();
            var controller     = new CandidateController(mockRepository.Object);

            // Act
            IHttpActionResult actionResult = controller.Put(candidate);
            var contentResult = actionResult as NegotiatedContentResult <Candidate>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual("123", contentResult.Content.CandidateId);
        }
예제 #5
0
        public void Put()
        {
            // Arrange
            CandidateController controller      = SetUpController();
            Candidate           candidateBefore = controller.Get(7);

            // Act
            candidateBefore.name = "Some Guy";
            var response = controller.Put(7, candidateBefore);


            Candidate candidateAfter = controller.Get(7);

            // Response status s/b 200 OK
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);

            // Name was changed
            Assert.AreEqual(candidateAfter.name, "Some Guy");

            // No change
            Assert.AreEqual(candidateAfter.phone, candidateBefore.phone);
        }
        public void ShouldAddSources()
        {
            var httpResult = controller.Get(1);
            var response   = httpResult as JsonResult <CandidateDTO>;
            var candidate  = response.Content;

            var candidateSource = candidate.Sources.First();

            string newPath = "path";

            candidateSource.Path = newPath;

            var newHttpResult = controller.Put(candidate.Id, candidate);
            var newResponse   = newHttpResult as JsonResult <CandidateDTO>;
            var newCandidate  = newResponse.Content;

            Assert.IsTrue(newCandidate.Sources.Any(x => x.Path == newPath));
        }