public void AdvertisementOfASingleEmployer_SetAllToInactive_WithInvalidUserName_ThrowsException() { var service = new AdvertisementService(context); var ex = Assert.Throws <ArgumentException>(() => service.ChangeAllAdvertisementsToInactive("")); Assert.That(ex.Message, Is.EqualTo("Invalid employer user name. (Parameter 'employerUserName')")); }
public void AdvertisementOfASingleEmployer_TestSetAllToInactive() { var service = new AdvertisementService(context); for (int i = 1; i <= 5; i++) { context.Advertisements.Add(new Advertisement { Name = "Advertisement1", Description = "An advertisement for a job.", Active = true, JobPositionId = this.jobPositionId, EmployerId = this.employerId }); } var employer = new Employer(); context.Employers.Add(employer); var employerId = employer.Id; context.Advertisements.Add(new Advertisement { Name = "Advertisement2", Description = "An advertisement for a job.", Active = true, JobPositionId = this.jobPositionId, EmployerId = employerId }); this.context.SaveChanges(); service.ChangeAllAdvertisementsToInactive(this.employerUserName); Assert.AreEqual(1, this.context.Advertisements.Count(a => a.Active == true)); }