Exemple #1
0
        public void Clone_DeepCopy()
        {
            Resource resource = new Resource("TV");
            Course course = new Course(10, 10, new List<Resource>() { resource });
            unit1.AssignedCourse = course;

            TimeUnit clone = (TimeUnit)unit1.Clone();

            Course course2 = new Course(20, 20, new List<Resource>());
            DateTime start2 = DateTime.Now.AddDays(1);
            DateTime end2 = start2.AddHours(1);

            // mutate course
            clone.AssignedCourse = course2;
            // mutate end
            clone.End = end2;
            // mutate start
            clone.Start = start2;

            Assert.AreEqual(course, unit1.AssignedCourse);
            Assert.AreEqual(start, unit1.Start);
            Assert.AreEqual(end, unit1.End);

            Assert.AreEqual(course2, clone.AssignedCourse);
            Assert.AreEqual(start2, clone.Start);
            Assert.AreEqual(end2, clone.End);
        }
Exemple #2
0
 public void AddCoursWithothExistingCheck(Course course)
 {
     CoursesAndLecturesPage.Instance.Navigate();
     CoursesAndLecturesPage.Instance.OpenCourseForm();
     CourseFormPage.Instance.FillForm(course);
     CourseFormPage.Instance.UpdateForm();
 }
Exemple #3
0
 public void AddCourse(Course course)
 {
     CoursesAndLecturesPage.Instance.Navigate();
     CoursesAndLecturesPage.Instance.DeleteCourseIfExisting(course);
     CoursesAndLecturesPage.Instance.OpenCourseForm();
     CourseFormPage.Instance.FillForm(course);
 }
        public IHttpActionResult PutCourse(int id, Course course)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != course.CourseId)
            {
                return BadRequest();
            }

            db.Entry(course).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CourseExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemple #5
0
        private void bind()
        {
            string id = Request.QueryString["id"].ToString();

            CourseBLL courBLL = new CourseBLL();
            course = courBLL.get(id);

            TextBox_courName.Text = course.Name;
            TextBox_credit.Text = course.Credit;
            TextBox_schoolHour.Text = course.SchoolHour;
        }
        public IHttpActionResult PostCourse(Course course)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Courses.Add(course);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = course.CourseId }, course);
        }
Exemple #7
0
 public bool CanFit(Course course)
 {
     bool result = false;
     foreach (BookableRoom room in Rooms)
     {
         if (room.CanFit(course))
         {
             result = true;
         }
     }
     return result;
 }
 public static void AssertCourseDoesntExist(this CoursesAndLecturesPage page, Course course)
 {
     var all = page.GridPage.GridTable;
     foreach (var row in all.BodyRows)
     {
         foreach (var value in row.Cells)
         {
             Assert.IsFalse(value.InnerText.Contains(course.NameBg), string.Format("The NameBg \"{0}\" is exist", course.NameBg));
             Assert.IsFalse(value.InnerText.Contains(course.NameEn), string.Format("The NameEn \"{0}\" is exist", course.NameEn));
             Assert.IsFalse(value.InnerText.Contains(course.UrlName), string.Format("The URlName \"{0}\" is exist", course.UrlName));
         }
     }
 }
Exemple #9
0
        protected void ImageButton_delete_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imageButton = sender as ImageButton;

            string id = imageButton.CommandArgument;

            Course course = new Course();
            course.Id = id;

            CourseBLL courBLL = new CourseBLL();
            courBLL.delete(course);

            Response.Write("<script>alert('删除成功!');location.href='showCourses.aspx';</script>");
        }
Exemple #10
0
        public void Equals_OtherObjectDifferentProperties_No()
        {
            Course course2 = new Course(10, 10, new List<Resource>() { resource1 });
            Assert.IsFalse(course1.Equals(course2));

            course2.RequiredResources = new List<Resource>() { resource1, new Resource("Audio") };
            Assert.IsFalse(course1.Equals(course2));

            course2.RequiredResources = resources1;
            course2.Students = 11;
            Assert.IsFalse(course1.Equals(course2));

            course2.Students = 10;
            course2.Duration = 11;
            Assert.IsFalse(course1.Equals(course2));
        }
Exemple #11
0
        public bool CanFit(Course course)
        {
            if (Seats < course.Students)
            {
                return false;
            }

            foreach (Resource resource in course.RequiredResources)
            {
                if (!Resources.Contains(resource))
                {
                    return false;
                }
            }
            return true;
        }
Exemple #12
0
        public object get(string id)
        {
            Course course = null;

            string selectSql = "SELECT * FROM t_course WHERE ID=@ID";

            SqlParameter[] sqlParas = new SqlParameter[] { new SqlParameter("@ID", id) };

            DataSet ds = SQLServerDBUtil.query(selectSql, sqlParas);

            if (ds.Tables[0].Rows.Count != 0)
            {
                course = new Course();
                course.Id = ds.Tables[0].Rows[0][0].ToString();
                course.Name = ds.Tables[0].Rows[0][1].ToString();
                course.Credit = ds.Tables[0].Rows[0][2].ToString();
                course.SchoolHour = ds.Tables[0].Rows[0][3].ToString();
            }

            return course;
        }
Exemple #13
0
        protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e)
        {
            if (check())
            {
                CourseBLL courBLL = new CourseBLL();

                string courName = TextBox_courName.Text.Trim();
                string credit = TextBox_credit.Text.Trim();
                string schoolHour = TextBox_schoolHour.Text.Trim();

                Course course = new Course();
                course.Name = courName;
                course.Credit = credit;
                course.SchoolHour = schoolHour;

                courBLL.save(course);

                Response.Write("<script>alert('添加成功!');location.href='addCourse.aspx';</script>");

            }
        }
        public static void AssertCourseIsCreated(this CoursesAndLecturesPage page, Course course)
        {
            page.Browser.Refresh();
            Thread.Sleep(10000);
            page.Browser.RefreshDomTree();

            var newRowIndex = page.GridPage.FindRow("Име (BG)", course.NameBg);
            var newRow = page.GridPage.GridTable.Rows[newRowIndex];
            var currentRow = page.GridPage.GridTable.Rows[newRowIndex - 1];

            Assert.AreEqual(course.NameEn, currentRow.Cells[3].InnerText);
            Assert.AreEqual(course.UrlName, currentRow.Cells[4].InnerText);
            Assert.AreEqual(course.Description, currentRow.Cells[5].InnerText);

            string color = string.Empty;
            var style = currentRow.Cells[6].Find.AllByTagName("span").FirstOrDefault().Attributes.FirstOrDefault().Value;
            var index = style.IndexOf('#') + 1;
            color = style.Substring(index, 6);
            //// Assert.AreEqual(course.Color, color);
            Assert.AreEqual(course.Order.ToString(), currentRow.Cells[7].InnerText);
            page.Browser.RefreshDomTree();
            course.Id = int.Parse(currentRow.Cells[1].InnerText);
        }
Exemple #15
0
 public void AddNewCourse(Course course)
 {
     this.AddCourse(course);
     Thread.Sleep(5000);
     CourseFormPage.Instance.UpdateForm();
 }
Exemple #16
0
        public void init()
        {
            resource1 = new Resource("TV");
            resource2 = new Resource("Projector");
            resource3 = new Resource("PC");

            resources1 = new List<Resource>() { resource1, resource2 };
            resources2 = new List<Resource>() { resource1, resource3 };

            room1 = new Room(10, resources1);
            room2 = new Room(10, new List<Resource>() { new Resource("Projector"), new Resource("TV") });
            course1 = new Course(10, 10, resources1);
            course2 = new Course(10, 10, resources2);
        }
Exemple #17
0
 public void EditUrlName(Course course, string newValue)
 {
     CoursesAndLecturesPage.Instance.OpenEditForm(course);
     CourseFormPage.Instance.EditInput(
         CourseFormPage.Instance.UrlName.Text,
         CourseFormPage.Instance.UrlName,
         newValue);
     CourseFormPage.Instance.UpdateForm();
 }
        public int Insert(Model.Course course)
        {
            CourseRepository c = new (new CollegeDBContext());

            return(c.Insert(course));
        }
 public static void AssertInvalidOrderValidationMessage(this CourseFormPage page, Course course)
 {
     var expected = string.Format(CourseForm.InvalidOrderMessage, course.Order);
     var actual = page.OrderValidationMessage.InnerText;
     Assert.AreEqual(expected, actual, string.Format(expected, Global.NullRefferenceMessage));
 }
Exemple #20
0
 public void Equals_OtherObjectSameProperties_Yes()
 {
     Course course2 = new Course(10, 10, resources2);
     Assert.IsTrue(course1.Equals(course2));
 }
        public Model.Course Update(Model.Course course)
        {
            CourseRepository c = new CourseRepository(new CollegeDBContext());

            return(c.Update(course));
        }
Exemple #22
0
 public void Constructor_ResourcesNull_EmptyList()
 {
     course1 = new Course(10, 10, null);
     Assert.IsEmpty(course1.RequiredResources);
 }
Exemple #23
0
 /// <summary>
 /// 删除课程信息
 /// </summary>
 /// <param name="course"></param>
 public void delete(Course course)
 {
     dal.delete(course);
 }
Exemple #24
0
 public void init()
 {
     resource1 = new Resource("TV");
     resource2 = new Resource("Projector");
     resources1 = new List<Resource>() { resource1, resource2 };
     resources2 = new List<Resource>() { new Resource("TV"), new Resource("Projector") };
     course1 = new Course(10, 10, resources1);
 }
Exemple #25
0
 /// <summary>
 /// 保存课程信息
 /// </summary>
 /// <param name="course"></param>
 public void save(Course course)
 {
     dal.save(course);
 }
Exemple #26
0
 public void CancelAddingNewCourse(Course course)
 {
     this.AddCourse(course);
     CourseFormPage.Instance.CancelForm();
 }
Exemple #27
0
 public void AssertExistingUrlNameValidetionMessage(Course course)
 {
     CourseFormPage.Instance.AssertExistingUrlValidationMessage();
     CourseFormPage.Instance.CancelForm();
     CoursesAndLecturesPage.Instance.DeleteCourseIfExisting(course);
 }
Exemple #28
0
 /// <summary>
 /// 更新课程信息
 /// </summary>
 /// <param name="course"></param>
 public void update(Course course)
 {
     dal.update(course);
 }
Exemple #29
0
 ////public void VerifyPageFormIsOpen()
 ////{
 ////    Thread.Sleep(1000);
 ////    CoursesAndLecturesPage.Instance.Browser.RefreshDomTree();
 ////    CourseFormPageAsserter.AssertTitle(CourseFormPage.Instance);
 ////}
 public void AssertIfCourseExist(Course course)
 {
     CoursesAndLecturesPage.Instance.AssertCourseIsCreated(course);
     CoursesAndLecturesPage.Instance.DeleteCourseIfExisting(course);
 }
        public List<Course> generateDefaultCourses()
        {
            // Resources
            Resource resource1 = new Resource("Projector");
            List<Resource> resources = new List<Resource>() { resource1 };

            // Courses
            Course course1 = new Course("Mathematics", 4 * 60, 5, null);
            Course course2 = new Course("French", 2 * 60, 15, null);
            Course course3 = new Course("Programming", 4 * 60, 30, null);
            Course course4 = new Course("English", 1 * 60 + 30, 10, null);
            Course course5 = new Course("English 2", 2 * 60, 5, null);
            List<Course> courses = new List<Course>() { course1, course2, course3, course4, course5 };
            //List<Course> courses = new List<Course>() { course1 };
            return courses;
        }
Exemple #31
0
 public void EditDescription(Course course, string newValue)
 {
     CoursesAndLecturesPage.Instance.OpenEditForm(course);
     CourseFormPage.Instance.EditInput(
         CourseFormPage.Instance.Description.InnerText,
         CourseFormPage.Instance.Description,
         newValue);
     CourseFormPage.Instance.UpdateForm();
 }
Exemple #32
0
        public void GetHashCode_DifferentFields_DifferentHashCode()
        {
            Course course2 = new Course("Test", 11, 12, null);

            Assert.AreNotEqual(course1, course2);
            Assert.AreNotEqual(course1.GetHashCode(), course2.GetHashCode());
        }