Example #1
0
        private void btnAddSubj_Click(object sender, EventArgs e)
        {
            bool isValid = txtFieldNotEmpty(txtSubject, lblSubject);

            if (!isValid)
            {
                return;
            }
            sbj.InsertSubject(new Subject {
                Name = txtSubject.Text.Trim()
            });
            grdSubjects.DataSource = sbj.GetSubjects().ToList();
            setcmbGrSbjSubject();
        }
Example #2
0
        public void InsertSubjectTest()
        {
            var expectedCount   = subjectManager.GetSubjects().Count();
            var expectedSubject = new Subject()
            {
                Name = "KRYTAH"
            };

            subjectManager.InsertSubject(expectedSubject);

            var actualCount   = subjectManager.GetSubjects().Count();
            var actualSubject = subjectManager.GetSubjects().Last();

            Assert.IsNotNull(actualSubject, "Subject is null");
            Assert.AreEqual(expectedSubject.Name, actualSubject.Name, "DB return different subject name");
            Assert.IsInstanceOfType(actualSubject, typeof(SubjectDTO), "Object type is wrong!");
            Assert.IsInstanceOfType(actualSubject.Id, typeof(int), "Id is not int");
            Assert.IsInstanceOfType(actualSubject.Name, typeof(string), "Subject name is not string");
            Assert.AreEqual(expectedCount + 1, actualCount, "added to DB more then one value");
        }