コード例 #1
0
        private void btnSubjUpdate_Click(object sender, EventArgs e)
        {
            bool isValid = txtFieldNotEmpty(txtSubject, lblSubject);

            if ((grdSubjects.DataSource == null) || !isValid)
            {
                return;
            }
            sbj.UpdateSubject(new Subject()
            {
                Id   = Convert.ToInt32(grdSubjects.CurrentRow.Cells[0].Value),
                Name = txtSubject.Text.Trim()
            });
            grdSubjects.DataSource = sbj.GetSubjects().ToList();
            setcmbGrSbjSubject();
        }
コード例 #2
0
        public void UpdateSubjectTest()
        {
            var expectedSubject = subjectManager.GetSubjects().Last();
            var expectedId      = expectedSubject.Id;

            expectedSubject.Name = "UpdateSubject";
            subjectManager.UpdateSubject(new Subject()
            {
                Id = expectedId, Name = expectedSubject.Name
            });

            var actualSubject = subjectManager.GetSubjects().Last();
            var actualId      = actualSubject.Id;

            Assert.IsNotNull(actualSubject, "Subject is null");

            Assert.AreEqual(expectedId, actualId, "DB return different id");
            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");
        }