Ejemplo n.º 1
0
        public void AddSubject()
        {
            IList <Subject> subjects = GetSubjects();
            Subject         subject  = new Subject()
            {
                Name = "Chemistry"
            };

            SubjectController controller = new SubjectController(subjects);

            ActionResult result = controller.Create(subject);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

            RedirectToRouteResult redirect = (RedirectToRouteResult)result;

            Assert.IsTrue(string.IsNullOrEmpty(redirect.RouteName));
            Assert.IsTrue(redirect.RouteValues.ContainsKey("id"));
            Assert.AreEqual(subject.Id, redirect.RouteValues["id"]);
            Assert.IsTrue(redirect.RouteValues.ContainsKey("action"));
            Assert.AreEqual("Details", redirect.RouteValues["action"]);

            Assert.IsTrue(subjects.Any(s => s.Name == "Chemistry"));
            Assert.AreNotEqual(0, subject.Id);
        }
Ejemplo n.º 2
0
        public void Can_Paginate()
        {
            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();
            Mock <IGenericRepository <Subject> > mockR = new Mock <IGenericRepository <Subject> >();

            mockR.Setup(r => r.GetAll()).Returns(() => new Subject[]
            {
                new Subject {
                    ID = 1, Name = "N1"
                },
                new Subject {
                    ID = 2, Name = "N2"
                },
                new Subject {
                    ID = 3, Name = "N3"
                },
                new Subject {
                    ID = 4, Name = "N4"
                },
                new Subject {
                    ID = 5, Name = "N5"
                }
            }.AsQueryable());
            mock.Setup(u => u.Subjects).Returns(mockR.Object);
            SubjectController controller = new SubjectController(mock.Object);

            controller.PageSize = 3;
            SubjectsListViewModel result = (SubjectsListViewModel)controller.List(2).Model;

            Subject[] subjectArray = result.Subjects.ToArray();
            Assert.IsTrue(subjectArray.Length == 2);
            Assert.AreEqual(subjectArray[0].Name, "N4");
            Assert.AreEqual(subjectArray[1].Name, "N5");
        }
 public SubjectManagerWindow(UserModel user)
 {
     this.user         = user;
     subjectController = new SubjectController();
     selectedSubject   = null;
     InitializeComponent();
 }
Ejemplo n.º 4
0
        public frmSettings()
        {
            InitializeComponent();
            // bật tắt button
            this.btnAdd.Enabled        = false;
            this.btnAddSubject.Enabled = false;
            ID = this.cbSubject.Items.Count + 1;

            faculty = FacultyController.GetAllFaculty();

            if (faculty.Count != 0)
            {
                foreach (Faculty item in faculty)
                {
                    this.cbFaculty.Items.Add(item.name);
                }
            }

            add = false;


            subject = SubjectController.GetListSubject();
            foreach (Subject item in subject)
            {
                this.cbSubject.Items.Add(item.subject);
                ID++;
            }
            index = 0;
        }
Ejemplo n.º 5
0
 public UserStartWindow(UserModel user, SubjectModel subject)
 {
     this.user            = user;
     this.selectedSubject = subject;
     subjectController    = new SubjectController();
     InitializeComponent();
 }
Ejemplo n.º 6
0
        public void Index_Contains_All_Subjects()
        {
            // Arrange (Организация)
            Mock <ISubjectRepository> mock = new Mock <ISubjectRepository>();

            mock.Setup(_ => _.Subjects).Returns(new List <Subject>
            {
                new Subject {
                    Id = 1, Abbreviation = "S1", DepartmentId = 1, Name = "Sub1"
                },
                new Subject {
                    Id = 2, Abbreviation = "S2", DepartmentId = 2, Name = "Sub2"
                },
                new Subject {
                    Id = 3, Abbreviation = "S3", DepartmentId = 3, Name = "Sub3"
                },
                new Subject {
                    Id = 4, Abbreviation = "S4", DepartmentId = 4, Name = "Sub4"
                },
                new Subject {
                    Id = 5, Abbreviation = "S5", DepartmentId = 5, Name = "Sub5"
                }
            });

            // Act (Действие)
            SubjectController controller = new SubjectController(mock.Object);

            List <Subject> result = ((IEnumerable <Subject>)controller.Index().ViewData.Model).ToList();

            // Assert (Утверждение)
            Assert.AreEqual(result.Count, 5);
            Assert.AreEqual(result[0].Id, 1);
            Assert.AreEqual(result[2].Id, 3);
        }
Ejemplo n.º 7
0
        private void DeleteSubject_Button_Click(object sender, RoutedEventArgs e)
        {
            Subjects subjectToDelete = new Subjects();

            try
            {
                var val = (Subjects)TimeTable_DataGrid.SelectedValue;
                subjectToDelete = val;
            }
            catch (Exception)
            {
                MessageBox.Show("Prosze zaznaczyc poprawny obiekt. ");
            }


            int deletedId = new int();

            try
            {
                deletedId = subjectToDelete.subjectId;

                SubjectController controller = new SubjectController();

                controller.DeleteSubject(deletedId);

                DataGridController gridController = new DataGridController(TimeTable_DataGrid);
                gridController.SetDataSourceForSubjects();
            }
            catch (Exception)
            {
                MessageBox.Show("Zaznacz element do usuniecia.");
            }
        }
Ejemplo n.º 8
0
        public void GetSubjects_ReturnsAListOfSubjects()
        {
            var controller = new SubjectController(SubjectServiceMock.Object);
            var subjects   = controller.Get();

            Assert.IsInstanceOfType(subjects, typeof(IEnumerable <Subject>), "Method does not return a list of subjects");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the form Shedule class.
        /// </summary>
        public Shedule()
        {
            InitializeComponent();
            cellPos = new int[2];

            grades       = new List <Grade>();
            subjects     = new List <Subject>();
            appointments = new List <Appointment>();

            taskController          = new TaskController();
            repeatingTaskController = new RepeatingTaskController();
            gradeController         = new GradeController();
            subjectController       = new SubjectController();
            appointmentController   = new AppointmentController();

            for (int i = 0; i < dgvShedule.Columns.Count; i++)
            {
                dgvShedule.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            for (int i = 0; i < 7; i++)
            {
                dgvShedule.Columns[i].HeaderText = DateTime.Today.AddDays(i).ToString("dd-MM-yyyy");
            }

            CleanupExpiredRecords();
            LoadToGrid(typeof(Task));
        }
Ejemplo n.º 10
0
 public frmSubject(Subject inputsSbj, frmMain frmMain)
 {
     subjectController = new SubjectController();
     sbj          = inputsSbj;
     this.frmMain = frmMain;
     InitializeComponent();
 }
Ejemplo n.º 11
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         bool isvalidated = validatefields();
         if (isvalidated)
         {
             Subject subject = new Subject();
             subject.offeredyear     = comboOfferedyear.SelectedItem.ToString();
             subject.lecturehours    = Convert.ToInt32(numericLhrs.Value);
             subject.offeredsemester = rdbSemester1.Checked ? 1 : 2;
             subject.tutorialhours   = Convert.ToInt32(numericThrs.Value);
             subject.subjectname     = txtSubjectname.Text;
             subject.labhours        = Convert.ToInt32(numericLabhrs.Value);
             subject.subjectcode     = txtSubjectcode.Text;
             subject.evoluationhours = Convert.ToInt32(numericEhrs.Value);
             string message = SubjectController.AddSubject(subject);
             MessageBox.Show(message);
             clear();
         }
         else
         {
             MessageBox.Show("please fill in all fields!");
         }
     }
     catch (NullReferenceException nre)
     {
         MessageBox.Show("please fill in all fields!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 12
0
        public void UpdateSubject()
        {
            IList <Subject> subjects   = GetSubjects();
            Subject         literature = subjects.Where(s => s.Name == "Literature").FirstOrDefault();
            Subject         subject    = new Subject()
            {
                Name = "SciFi"
            };

            SubjectController controller = new SubjectController(subjects);

            ActionResult result = controller.Update(literature.Id, subject);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

            RedirectToRouteResult redirect = (RedirectToRouteResult)result;

            Assert.IsTrue(string.IsNullOrEmpty(redirect.RouteName));
            Assert.IsTrue(redirect.RouteValues.ContainsKey("id"));
            Assert.AreEqual(literature.Id, redirect.RouteValues["id"]);
            Assert.IsTrue(redirect.RouteValues.ContainsKey("action"));
            Assert.AreEqual("Details", redirect.RouteValues["action"]);

            Assert.IsTrue(subjects.Any(s => s.Name == "SciFi"));
            Assert.AreEqual(literature.Id, subjects.Where(s => s.Name == "SciFi").Single().Id);
        }
Ejemplo n.º 13
0
        public SubjectForm()
        {
            InitializeComponent();
            controller       = new SubjectController();
            InsertedSubjects = new List <Subject>();

            FormClosed += SubjectForm_Closed;
        }
Ejemplo n.º 14
0
 public frmChart()
 {
     InitializeComponent();
     subjectController = new SubjectController();
     classController   = new ClassController();
     studentController = new StudentController();
     scoreController   = new ScoreController();
 }
Ejemplo n.º 15
0
        public void UpdateSubject_ServiceMethodIsCalled()
        {
            var controller = new SubjectController(SubjectServiceMock.Object);

            controller.Put(12, Fakes.GetSubject());

            SubjectServiceMock.Verify(x => x.Update(It.IsAny <int>(), It.IsAny <Subject>()), Times.Once);
        }
Ejemplo n.º 16
0
        public void AddSubject_ServiceMethodIsCalled()
        {
            var controller = new SubjectController(SubjectServiceMock.Object);

            controller.Post(Fakes.GetSubject());

            SubjectServiceMock.Verify(x => x.Add(It.IsAny <Subject>()), Times.Once);
        }
Ejemplo n.º 17
0
 public SubjectView(Member member, BasicForm form)
 {
     InitializeComponent();
     _LoginInfo         = member;
     _Mother            = form;
     _SubjectController = new SubjectController();
     _SelectedOrder     = "";
 }
Ejemplo n.º 18
0
        private void LoadCmbSubject()
        {
            SubjectController subjectController = new SubjectController();
            List <SUBJECT>    subjects          = subjectController.GetAll();

            cmbSubject.ValueMember   = "SUBJECTID";
            cmbSubject.DisplayMember = "NAME";
            cmbSubject.DataSource    = subjects;
        }
Ejemplo n.º 19
0
        public void SetUp()
        {
            _subjectService    = new Mock <ISubjectService>();
            _subjectController = new SubjectController(_subjectService.Object);

            subject = new SubjectDTO {
                Id = 1, Name = "SubjectName"
            };
        }
Ejemplo n.º 20
0
        public void SetUp()
        {
            _subjectService    = new Mock <ICrudInterface <SubjectDto> >();
            _subjectController = new SubjectController(_subjectService.Object);

            _subject = new SubjectDto {
                Id = "subject1", Name = "TRPZ", LecturerId = "lecturer1"
            };
        }
Ejemplo n.º 21
0
 public frmTeacherAssignment(string _classID)
 {
     InitializeComponent();
     subjectController  = new SubjectController();
     classController    = new ClassController();
     teacherController  = new TeacherController();
     teachingController = new TeachingController();
     classID            = _classID;
 }
Ejemplo n.º 22
0
        private void frmAddProject_Load(object sender, EventArgs e)
        {
            this.cbCourse.SelectedIndex  = 0;
            this.cbSubject.SelectedIndex = 0;
            List <Subject> sub = SubjectController.GetListSubject();

            foreach (Subject item in sub)
            {
                this.cbSubject.Items.Add(item.subject);
            }

            // Dùng dictionary để hiển thị
            dicStudent    = new Dictionary <string, string>();
            dicInstructor = new Dictionary <string, string>();

            listError = new List <ErrorProvider>();
            for (int i = 0; i < 8; i++)
            {
                ErrorProvider err = new ErrorProvider();
                listError.Add(err);
            }

            // chế độ add
            if (project.idProject == null)
            {
                this.listboxResultStudent.Visible    = false;
                this.listboxStudent.Visible          = false;
                this.listboxInstructor.Visible       = false;
                this.listboxResultInstructor.Visible = false;
            }
            else
            {
                this.btnAdd.Text  = "Lưu";
                this.lblName.Text = "CHỈNH SỬA ĐỀ TÀI";

                this.listboxStudent.Visible    = false;
                this.listboxInstructor.Visible = false;

                this.txbID.Text          = project.idProject;
                this.txbProjectName.Text = project.name;

                foreach (Student item in project.listStudent)
                {
                    this.listboxResultStudent.Items.Add(item.name);
                    dicStudent.Add(item.MSSV, item.name);
                }
                foreach (Instructor item in project.listInstructor)
                {
                    this.listboxResultInstructor.Items.Add(item.name);
                    dicInstructor.Add(item.id, item.name);
                }

                this.cbSubject.Text = project.subject;
                this.cbCourse.Text  = project.course;
            }
        }
 /// <summary>
 /// Initializes a new instance of the form EditSubject class.
 /// </summary>
 /// <param name="model">Subject details to edit.</param>
 public EditSubject(Subject model)
 {
     InitializeComponent();
     this.model        = model;
     subjectController = new SubjectController();
     gradeController   = new GradeController();
     grades            = gradeController.Details();
     subjects          = subjectController.Details();
     txtName.Text      = model.Name;
 }
Ejemplo n.º 24
0
 public frmStudentScoreboard(string _studentID, string _studentName, int _grade)
 {
     InitializeComponent();
     studentID         = _studentID;
     grade             = _grade;
     studentName       = _studentName;
     subjectController = new SubjectController();
     scoreController   = new ScoreController();
     studentController = new StudentController();
 }
Ejemplo n.º 25
0
        private void setsubjectcombodata()
        {
            comboSubject.Items.Clear();
            DataTable dt = SubjectController.FilterSubjects("");

            comboSubject.DataSource    = dt;
            comboSubject.DisplayMember = "Subject Name";
            comboSubject.ValueMember   = "ID";
            comboSubject.SelectedValue = 0;
            comboSubject.SelectedIndex = -1;
        }
Ejemplo n.º 26
0
    public override void OnInspectorGUI()
    {
        instance = target as SubjectController;

        base.DrawDefaultInspector();

        if (GUILayout.Button("Reset Tracker"))
        {
            instance.ResetTracker();
        }
    }
Ejemplo n.º 27
0
        private void setsubjectcombodata()
        {
            comboSubject.Items.Clear();
            DataTable dt = SubjectController.FilterSubjects("");

            dt.Rows.Add(0, "Select Subject");
            dt.DefaultView.Sort        = "ID asc";
            comboSubject.DataSource    = dt;
            comboSubject.DisplayMember = "Subject Name";
            comboSubject.ValueMember   = "ID";
            comboSubject.SelectedValue = 0;
        }
Ejemplo n.º 28
0
        public void WhenIdIsNotNullButSubjectVMIsNullShouldReturnError()
        {
            Mock <ISubjectService> _subjectServiceMock = new Mock <ISubjectService>();

            _subjectServiceMock.Setup(s => s.GetSubject(It.IsAny <Expression <Func <Subject, bool> > >())).Returns(() => null);
            SubjectController _subjectController = new SubjectController(_subjectServiceMock.Object, _teacherServiceMock.Object, null, _mapperMock.Object, _localizerMock.Object, _loggerFactoryMock.Object);

            int?id = 99;

            var result = (ViewResult)_subjectController.CreateOrUpdateSubject(id);

            Assert.Equal("Error", result.ViewName);
        }
Ejemplo n.º 29
0
        public void POSTShouldReturnSameViewWhenStateIsNotValid()
        {
            Mock <ISubjectService> _subjectServiceMock = new Mock <ISubjectService>();

            _subjectServiceMock.Setup(s => s.GetSubject(It.IsAny <Expression <Func <Subject, bool> > >())).Returns(() => _correctSubjectVM);
            SubjectController _subjectController = new SubjectController(_subjectServiceMock.Object, _teacherServiceMock.Object, null, _mapperMock.Object, _localizerMock.Object, _loggerFactoryMock.Object);

            _subjectController.ModelState.AddModelError("test", "test");

            var result = (ViewResult)_subjectController.CreateOrUpdateSubject(new SubjectForCreateOrUpdateDTO());

            Assert.Equal("CreateOrUpdateSubject", result.ViewName);
        }
Ejemplo n.º 30
0
        public void POSTShouldCallCreateOrUpdateOnceAdndRedirectToIndexIfModelStateIsValidAndNotExistsAlready()
        {
            Mock <ISubjectService> _subjectServiceMock = new Mock <ISubjectService>();

            _subjectServiceMock.Setup(s => s.GetSubject(It.IsAny <Expression <Func <Subject, bool> > >())).Returns(() => _correctSubjectVM);
            _subjectServiceMock.Setup(s => s.CreateOrUpdate(_correctSubjectDTO)).Returns(() => _correctSubjectVM);  //returns object so it was succesfully created
            SubjectController _subjectController = new SubjectController(_subjectServiceMock.Object, _teacherServiceMock.Object, null, _mapperMock.Object, _localizerMock.Object, _loggerFactoryMock.Object);

            var result = (RedirectToActionResult)_subjectController.CreateOrUpdateSubject(_correctSubjectDTO);

            _subjectServiceMock.Verify(m => m.CreateOrUpdate(_correctSubjectDTO), Times.Once);
            Assert.Equal("Index", result.ActionName);
        }
Ejemplo n.º 31
0
 public static SubjectController Fixture()
 {
     SubjectController controller = new SubjectController(new SubjectRepository(), "", new LoginView());
     return controller;
 }
Ejemplo n.º 32
0
 void Awake()
 {
     Instance = this;
 }