コード例 #1
0
        public void PostShouldAddNewCandidateToCandidateList()
        {
            var controller = new RecruitmentController();

            controller.SetCandidates(this.GetCandidatesTestData());

            var testData = this.GetCandidatesTestData();

            Assert.Equal(RecruitmentController.candidates.Count, testData.Count);

            var newCandidate = new Candidate {
                Id = Guid.NewGuid(), FirstName = "New", LastName = "Candidate"
            };
            var actionResult = controller.Post(newCandidate);

            // Asserts
            Assert.IsType <CreatedAtActionResult>(actionResult);

            var createdAtActionResult = actionResult as CreatedAtActionResult;
            var candidate             = createdAtActionResult.Value as Candidate;

            Assert.Equal(RecruitmentController.candidates.Count, testData.Count + 1);

            var findNewCandidate = RecruitmentController.candidates.Find(i => i.Id == candidate.Id);

            Assert.NotNull(findNewCandidate);
        }
コード例 #2
0
        public void PostShouldReturnCreatedWithNewCandidate()
        {
            var controller = new RecruitmentController();

            controller.SetCandidates(this.GetCandidatesTestData());

            var newCandidate = new Candidate {
                Id = Guid.NewGuid(), FirstName = "New", LastName = "Candidate"
            };
            var actionResult = controller.Post(newCandidate);

            // Assserts
            Assert.IsType <CreatedAtActionResult>(actionResult);

            var createdAtActionResult = actionResult as CreatedAtActionResult;
            var candidate             = createdAtActionResult.Value as Candidate;

            Assert.Equal(newCandidate, candidate);
        }