Example #1
0
        public void CandidateWithoutRelationToAdvertisement_WhenRemoved_ThrowsException()
        {
            var service = new AdvertisementCandidateService(context);

            var ex = Assert.Throws <ArgumentException>(() => service.RemoveCandidateFromAdvertisement(this.advertisement.Id, this.candidate.Id));

            Assert.That(ex.Message, Is.EqualTo("Candidate does not have relation to advertisement (Parameter 'candidateId')"));
        }
Example #2
0
        public void Candidate_WhenRemovedFromAdvertisementWithInvalidId_ThrowsException()
        {
            var service = new AdvertisementCandidateService(context);

            var ex = Assert.Throws <ArgumentException>(() => service.RemoveCandidateFromAdvertisement(2, this.candidate.Id));

            Assert.That(ex.Message, Is.EqualTo("Invalid advertisement id. (Parameter 'advertisementId')"));
        }
Example #3
0
        public void Candidate_CanBeRemovedFromAdvertisement()
        {
            var otherCandidate = new Candidate();
            var relation1      = new AdvertisementCandidate()
            {
                Advertisement = this.advertisement, Candidate = this.candidate
            };
            var relation2 = new AdvertisementCandidate()
            {
                Advertisement = this.advertisement, Candidate = otherCandidate
            };

            advertisement.Candidates.Add(relation1);
            advertisement.Candidates.Add(relation2);
            candidate.Advertisements.Add(relation1);
            otherCandidate.Advertisements.Add(relation2);
            this.context.SaveChanges();

            var service = new AdvertisementCandidateService(context);

            Assert.AreEqual(2, this.context.AdvertisementsCandidates.Count());
            service.RemoveCandidateFromAdvertisement(this.advertisement.Id, this.candidate.Id);
            Assert.AreEqual(1, this.context.AdvertisementsCandidates.Count());
        }