public void TestAddCandidateAndProjectTogether() { TestCandidate candidate = new TestCandidate(); candidate.Name = "Mohan"; CandidateProject project = new CandidateProject(); project.Name = "ResumePro"; candidate.AddProject(project); candidate = SaveAndReFetch(candidate); Assert.AreEqual(candidate.Projects.Count, 1); }
public ActionResult AddCandidateProject(CandidateProject cp) { ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email"); string id = User.Identity.GetUserId(); cp.UserId = id; if (cp.Id > 0) { db.Entry(cp).State = EntityState.Modified; db.SaveChanges(); } else { db.CandidateProjects.Add(cp); db.SaveChanges(); } return(View(cp)); }
public void TestRemoveProjectDirect() { TestCandidate candidate = new TestCandidate(); candidate.Name = "Palaksha"; CandidateProject project = new CandidateProject(); project.Name = "AppServer"; candidate.AddProject(project); Save(candidate); project = Repository <CandidateProject> .FindOne(Expression.Eq("Name", "AppServer")); candidate.RemoveProject(project); SaveAndReFetch(candidate); Assert.AreEqual(candidate.Projects.Count, 0); }
public void TestUpdateProjectDirect() { TestCandidate candidate = new TestCandidate(); candidate.Name = "Palaksha"; CandidateProject project = new CandidateProject(); project.Name = "AppServer"; candidate.AddProject(project); Save(candidate); project = Repository <CandidateProject> .FindOne(Expression.Eq("Name", "AppServer")); project.Name = "Changed" + project.Name; project = Collection.First(candidate.Projects); Assert.IsTrue(project.Name.StartsWith("Changed")); }
public void TestUpdateProject() { TestCandidate candidate = new TestCandidate(); candidate.Name = "Palaksha"; CandidateProject project = new CandidateProject(); project.Name = "AppServer"; candidate.AddProject(project); candidate = SaveAndReFetch(candidate); project = Collection.First(candidate.Projects); project.Name = "Changed" + project.Name; candidate = SaveAndReFetch(candidate); project = Collection.First(candidate.Projects); Assert.IsTrue(project.Name.StartsWith("Changed")); }
public void TestAddCandidateAndWorkProfileAndProject() { TestCandidate candidate = new TestCandidate(); candidate.Name = "Mohan"; CandidateWorkProfile workProfile; Relation.AddNew(candidate, out workProfile); workProfile.CompanyName = "HirePro"; CandidateProject project = new CandidateProject(); project.Name = "ResumePro"; Relation.Add(workProfile, project); candidate = SaveAndReFetch(candidate); Assert.AreEqual(Relation.Count <CandidateWorkProfile>(candidate), 1); Assert.AreEqual(Relation.Count <CandidateProject>(workProfile), 1); Assert.AreEqual( CollectionHelper.First(Relation.Collection <CandidateProject>(workProfile)).Name, "ResumePro"); }
public void TestRemoveProject() { TestCandidate candidate = new TestCandidate(); candidate.Name = "Palaksha"; CandidateProject project = new CandidateProject(); project.Name = "AppServer"; candidate.AddProject(project); candidate = SaveAndReFetch(candidate); project = Collection.First(candidate.Projects); With.Transaction(delegate { candidate.RemoveProject(project); }); candidate = SaveAndReFetch(candidate); Assert.AreEqual(candidate.Projects.Count, 0); }