public void RemoveWorkWeekTest() { var repository = new Repository(); var workWeekBLL = new WorkWeekBLL(repository); var subjectBll = new SubjectBLL(repository); var workWeek = workWeekBLL.CreateWorkWeek("test"); var subj1 = subjectBll.CreateNew("subj1", Day.Thursday, DateTime.Now, 1250, "qwerty", workWeek); var subj2 = subjectBll.CreateNew("subj2", Day.Wednesday, DateTime.Now, 1251, "asd", workWeek); var subj3 = subjectBll.CreateNew("subj3", Day.Wednesday, DateTime.Now, 1251, "asd", workWeek); Assert.True(workWeekBLL.Remove(workWeek.Id)); Assert.False(workWeekBLL.Remove(workWeek.Id)); }
public void GetAllTest() { var repository = new Repository(); var workWeekBLL = new WorkWeekBLL(repository); var subjectBll = new SubjectBLL(repository); var workWeek = workWeekBLL.CreateWorkWeek("test"); var workWeek2 = workWeekBLL.CreateWorkWeek("test2"); var subj0 = subjectBll.CreateNew("subj0", Day.Wednesday, DateTime.Now, 1249, "jh", workWeek2); var subj1 = subjectBll.CreateNew("subj1", Day.Thursday, DateTime.Now, 1250, "qwerty", workWeek); var subj2 = subjectBll.CreateNew("subj2", Day.Wednesday, DateTime.Now, 1251, "asd", workWeek); //сравнить списки var weeks = workWeekBLL.GetAll(); }
public void CreateSubjectTest() { //Arrange var repository = new Mock <IRepository>(); var subjectBll = new SubjectBLL(repository.Object); var workWeekBLL = new Mock <IWorkWeekBLL>(); workWeekBLL.Setup(w => w.CreateWorkWeek("test")) .Returns(ForMockWorkWeek()); var workWeek = workWeekBLL.Object.CreateWorkWeek("test"); //repository.Setup(x => x.Save()).Returns() // var subject = new Subject("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A. V."); //subject.WorkWeek = workWeek; //Act //var subjectTest = subjectBll.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A. V.", workWeek); Assert.Throws <ArgumentOutOfRangeException>(() => subjectBll.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A. V.", workWeek)); //Assert //var res = repository.Object.GetWorkWeekById(workWeek.Id); }
public void ChangeSubjectTest() //+ { // given var repository = new Repository(); var subjectBll = new SubjectBLL(repository); var workWeekBll = new WorkWeekBLL(repository); var workWeek = workWeekBll.CreateWorkWeek("test"); var source = subjectBll.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Ivanov A. V.", workWeek); var dest = new Subject("NewTestName", Day.Wednesday, DateTime.Now, 1248, "Ivanov A.V."); subjectBll.ChangeSubjectInfo(source, dest); // when var res = repository.GetWorkWeekById(workWeek.Id); var collection = res.Subjects; var resSubject = new List <Subject>(collection)[0]; // then var resSubjects = collection; Assert.AreEqual(resSubject.Name, source.Name); Assert.AreEqual(resSubject.FullName, source.FullName); Assert.AreEqual(resSubject.WorkWeek.Id, source.WorkWeek.Id); Assert.AreEqual(resSubject.DayOfWeek, source.DayOfWeek); Assert.AreEqual(resSubject.AudienceNumber, dest.AudienceNumber); }
public void CreateSubjectTest() //+ { // given var repository = new Repository(); var subjectBll = new SubjectBLL(repository); var workWeekBll = new WorkWeekBLL(repository); var workWeek = workWeekBll.CreateWorkWeek("test"); var subject = subjectBll.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Ivanov A. V.", workWeek); workWeek.Subjects.Add(subject); var workWeek2 = workWeekBll.CreateWorkWeek("test2"); // whenд var res = repository.GetWorkWeekById(workWeek.Id); // then Assert.AreEqual(workWeek.Id, res.Id); var resSubjects = res.Subjects; var workWeekSubject = new List <Subject>(workWeek.Subjects)[0]; var resSubject = new List <Subject>(resSubjects)[0]; Assert.AreEqual(res.Id, workWeek.Id); Assert.AreNotEqual(res.Id, workWeek2.Id); Assert.AreEqual(resSubject.Id, workWeekSubject.Id); Assert.AreEqual(resSubject.Name, workWeekSubject.Name); Assert.AreEqual(resSubject.AudienceNumber, workWeekSubject.AudienceNumber); Assert.AreEqual(resSubject.FullName, workWeekSubject.FullName); Assert.AreEqual(resSubject.WorkWeek.Id, workWeekSubject.WorkWeek.Id); Assert.AreEqual(resSubject.DayOfWeek, workWeekSubject.DayOfWeek); }
public void CreateWorkWeekTest() { //Arrange var repository = new Repository(); var workWeekBLL = new WorkWeekBLL(repository); var subjectBll = new SubjectBLL(repository); //Act var workWeek = workWeekBLL.CreateWorkWeek("test"); var subj1 = subjectBll.CreateNew("subj1", Day.Thursday, DateTime.Now, 1252, "qwerty", workWeek); var subj2 = subjectBll.CreateNew("subj2", Day.Wednesday, DateTime.Now, 1253, "asd", workWeek); //Assert var res = repository.GetWorkWeekById(workWeek.Id); var res1 = repository.GetSubjectById(subj1.Id); var res2 = repository.GetSubjectById(subj2.Id); }
public void GetSubjectByIdTest_Throw_ArgumentOutOfRangeException() { var repository = new Repository(); var workWeek = new WorkWeekBLL(repository).CreateWorkWeek("test1"); var subjectBLL = new SubjectBLL(repository); var source = subjectBLL.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A.V.", workWeek); subjectBLL.RemoveSubject(source.Id); Assert.Throws <ArgumentOutOfRangeException>(() => subjectBLL.GetSubjectById(source.Id)); }
public void RemoveSubjectTest() { var repository = new Repository(); var subjectBLL = new SubjectBLL(repository); var workWeekBLL = new WorkWeekBLL(repository); var workWeek = workWeekBLL.CreateWorkWeek("test 1"); var source = subjectBLL.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A.V.", workWeek); Assert.True(subjectBLL.RemoveSubject(source.Id)); Assert.False(subjectBLL.RemoveSubject(source.Id)); }
public void ChangeSubjectTest() { var repository = new Repository(); var subjectBLL = new SubjectBLL(repository); var workWeekBLL = new WorkWeekBLL(repository); var workWeek = workWeekBLL.CreateWorkWeek("test 1"); var source = subjectBLL.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A.V.", workWeek); var dest = new Subject("NewTestName", Day.Wednesday, DateTime.Now, 1248, "Ivanov A.V."); subjectBLL.ChangeSubjectInfo(source, dest); var res = repository.GetWorkWeekById(workWeek.Id); }
public void CreateSubjectTest() { //Arrange var repository = new Repository(); var subjectBll = new SubjectBLL(repository); var workWeekBLL = new WorkWeekBLL(repository); var workWeek = workWeekBLL.CreateWorkWeek("test"); //Act var subject = subjectBll.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A. V.", workWeek); //Assert var res = repository.GetWorkWeekById(workWeek.Id); }
public void RemoveSubjectTest() { // given var repository = new Repository(); var subjectBLL = new SubjectBLL(repository); var workWeekBLL = new WorkWeekBLL(repository); var workWeek = workWeekBLL.CreateWorkWeek("test 1"); var source = subjectBLL.CreateNew("testName", Day.Monday, DateTime.Now, 1234, "Vedenin A.V.", workWeek); Assert.True(subjectBLL.RemoveSubject(source.Id)); Assert.False(subjectBLL.RemoveSubject(source.Id)); var res = repository.GetWorkWeekById(workWeek.Id); Assert.AreEqual(0, res.Subjects.Count); }