public void AfterDeleteSubjectCodeIsAvailableToCreateNewSubject() { ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations(); Subject subject = new Subject(1000, "Logic"); subjectOperations.AddSubject(subject); subjectOperations.DeleteSubjectByCode(subject.GetCode()); Subject anotherSubject = new Subject(1000, "Logic"); subjectOperations.AddSubject(anotherSubject); Assert.IsNotNull(this.FindSubjectOnSystem(anotherSubject.GetCode())); }
public void AddSubjectToSystem() { ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations(); Subject newSubject = new Subject(1, "Logic"); subjectOperations.AddSubject(newSubject); Assert.IsNotNull(this.FindSubjectOnSystem(newSubject.GetCode())); }
public void DeleteSubject() { ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations(); Subject subject = new Subject(1000, "Logic"); subjectOperations.AddSubject(subject); subjectOperations.DeleteSubjectByCode(1000); Assert.IsNull(this.FindSubjectOnSystem(1000)); }
public void TryToAddSubjectThatAlreadyExistsToSystem() { try { ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations(); Subject firstTeacher = new Subject(1, "Logic"); Subject secondTeacher = new Subject(1, "Logic"); subjectOperations.AddSubject(firstTeacher); subjectOperations.AddSubject(secondTeacher); Assert.Fail(); } catch (CoreException ex) { Assert.IsTrue(ex.Message.Equals("Subject already exists.")); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void ModifySubject() { ISubjectLogic subjectOperations = DummyProvider.GetInstance.GetSubjectOperations(); int subjectCode = 1; Subject subject = new Subject(subjectCode, "Logic"); subjectOperations.AddSubject(subject); subject.SetName("LogicModified"); subjectOperations.ModifySubjectByCode(subjectCode, subject); Subject modifiedSubject = subjectOperations.GetSubjectByCode(subjectCode); Assert.AreEqual(modifiedSubject.GetName(), "LogicModified"); }
private void buttonAdd_Click(object sender, EventArgs e) { this.labelOk.Visible = false; this.labelError.Visible = false; try { this.labelError.Visible = false; string name; int code; Subject subject = new Subject(); if (int.TryParse(this.textBoxSubjectCode.Text, out code)) { if (!string.IsNullOrWhiteSpace(this.textBoxSubjectName.Text)) { subject.Code = code; name = this.textBoxSubjectName.Text; subject.Name = name; ISubjectLogic subjectsOperations = Provider.GetInstance.GetSubjectOperations(); subjectsOperations.AddSubject(subject); this.ClearAddSubjectForm(); this.ShowCorrectlyAddedSubjectMessage(code, name); } else { this.labelError.Visible = true; this.labelError.Text = "Subject's name must be a not empty string"; } } else { this.labelError.Visible = true; this.labelError.Text = "Subject's code must be a number"; } } catch (CoreException ex) { this.labelError.Text = ex.Message; this.labelError.Visible = true; } catch (Exception ex) { this.labelError.Text = ex.Message; this.labelError.Visible = true; } }
public ActionResult Create(SubjectCreateVM subject, int id) { try { if (ModelState.IsValid) { _subjectLogic.AddSubject(Mapper.Map <SubjectCreateVM, Subject>(subject)); // return RedirectToAction("IndexForTeacher",id); return(RedirectToAction("Index", "Home")); } } catch (Exception ex) { ModelState.AddModelError(String.Empty, ex); } return(View(subject)); }