コード例 #1
0
ファイル: SubjectBLLTests.cs プロジェクト: vedandays/Schedule
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public void RemoveDayTest()
        {
            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 subj3     = subjectBll.CreateNew("subj3", Day.Wednesday, DateTime.Now, 1252, "sa", workWeek);

            Assert.True(workWeekBLL.RemoveDay(workWeek.Id, Day.Wednesday));
        }
コード例 #4
0
ファイル: SubjectBLLTests.cs プロジェクト: vedandays/Schedule
        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);
        }
コード例 #5
0
        public void CreateWorkWeekInvoke()
        {
            //Arrange

            var repository = new Mock <IRepository>();
            var bll        = new WorkWeekBLL(repository.Object);

            //Act, Assert
            new Action(() => bll.CreateWorkWeek("test")).Invoke();
        }
コード例 #6
0
        public JObject Post([FromBody] JObject jsonResult) //+
        {
            WorkWeekDTO workWeekDto = JsonConvert.DeserializeObject <WorkWeekDTO>(jsonResult.ToString());
            WorkWeek    workWeek    = workWeekDto.MapToModel();
            WorkWeekBLL workWeekBll = new WorkWeekBLL(repository);

            workWeekBll.CreateWorkWeek(workWeek);

            return(jsonResult);
        }
コード例 #7
0
ファイル: SubjectBLLTests.cs プロジェクト: Lmglk/Schedule
        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));
        }
コード例 #8
0
ファイル: SubjectBLLTests.cs プロジェクト: Lmglk/Schedule
        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);
        }
コード例 #9
0
ファイル: SubjectBLLTests.cs プロジェクト: Lmglk/Schedule
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: SubjectBLLTests.cs プロジェクト: vedandays/Schedule
        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);
        }