public void With_id_of_any_seed_job_Then_that_seed_job_is_deleted_and_is_returned(int id) { Job deletedJob; Job missingJob; int initialJobCount; int newJobCount; using (var context = DSCContextFactory.InMemoryContext()) { var repository = new Models.JobRepository(context); initialJobCount = context.Jobs.Count(); deletedJob = repository.Delete(context.Jobs.Find(id)); newJobCount = context.Jobs.Count(); missingJob = context.Jobs.Find(id); } Assert.True(newJobCount == initialJobCount - 1, "Job count is incorrect"); Assert.Null(missingJob); Assert.IsType <Job>(deletedJob); }
public void With_a_new_job_Then_a_new_job_is_added_and_returned_with_a_new_id_value() { var newJob = new Job { Name = "new job", IsCompleted = false }; Job savedJob; int initialJobCount; int newJobCount; using (var context = DSCContextFactory.InMemoryContext()) { var repository = new Models.JobRepository(context); initialJobCount = context.Jobs.Count(); savedJob = repository.Save(newJob); newJobCount = context.Jobs.Count(); } Assert.True(newJobCount == initialJobCount + 1, "Job count is incorrect"); Assert.True(Comparator.JobsAreIdentical(newJob, savedJob), "Jobs are not identical"); Assert.True(savedJob.Id == newJobCount, "Job has incorrect Id value"); }
public void With_id_of_any_seed_job_Then_that_seed_job_is_returned(int id) { Job job; using (var context = DSCContextFactory.InMemoryContext()) { var repository = new Models.JobRepository(context); job = repository.GetById(id); } var seedDataJob = SeedData.Jobs().FirstOrDefault(j => j.Name.EndsWith(id.ToString())); Assert.True(Comparator.JobsAreIdentical(seedDataJob, job), "Jobs are not identical"); }
public void With_a_existing_job_Then_an_existing_job_is_edited_and_returned(int id) { Job existingJob; Job savedJob; using (var context = DSCContextFactory.InMemoryContext()) { var repository = new Models.JobRepository(context); existingJob = context.Jobs.Find(id); existingJob.Name = existingJob.Name + "{mod}"; existingJob.IsCompleted = !existingJob.IsCompleted; savedJob = repository.Save(existingJob); } Assert.True(existingJob == savedJob, "Jobs are not equal"); }