예제 #1
0
    public void Grade_returns_null_if_not_represented()
    {
        var school = new School();

        school.Add("Franklin", 5);
        school.Add("Bradley", 5);
        school.Add("Jeff", 1);

        var actual = school.Grade(3);

        Assert.Empty(actual);
    }
예제 #2
0
        public void GivenTwoEqualsSchoolGroups_WhenAdd_ThenOnlyOneCreateInSchool()
        {
            SchoolGroup firstClass  = new SchoolGroup("A");
            SchoolGroup secondClass = new SchoolGroup("A");

            School school = new School();

            school.Add(firstClass);
            school.Add(secondClass);

            Assert.AreEqual(1, school.GetAllSchoolGroups().Count);
        }
예제 #3
0
        public void GivenTwoDifferentSchoolGroups_WhenAdd_ThenAllCreateInSchool()
        {
            SchoolGroup firstClass  = new SchoolGroup("A");
            SchoolGroup secondClass = new SchoolGroup("B");

            School school = new School();

            school.Add(firstClass);
            school.Add(secondClass);

            Assert.AreEqual(2, school.GetAllSchoolGroups().Count);
        }
예제 #4
0
    public void Adding_students_to_different_grades_adds_them_to_the_same_sorted_roster()
    {
        var school = new School();

        school.Add("Chelsea", 3);
        school.Add("Logan", 7);

        var actual = school.Roster();

        var expected = new[] { "Chelsea", "Logan" };

        Assert.Equal(expected, actual);
    }
예제 #5
0
    public void Adding_more_students_adds_them_to_the_sorted_roster()
    {
        var school = new School();

        school.Add("Blair", 2);
        school.Add("James", 2);
        school.Add("Paul", 2);

        var actual = school.Roster();

        var expected = new[] { "Blair", "James", "Paul" };

        Assert.Equal(expected, actual);
    }
예제 #6
0
    public void Grade_returns_the_students_in_that_grade_in_alphabetical_order()
    {
        var school = new School();

        school.Add("Franklin", 5);
        school.Add("Bradley", 5);
        school.Add("Jeff", 1);

        var actual = school.Grade(5);

        var expected = new[] { "Bradley", "Franklin" };

        Assert.Equal(expected, actual);
    }
예제 #7
0
    public void Adding_douplcate_student_name_should_be_ignored()
    {
        var school = new School();

        school.Add("Franklin", 5);
        school.Add("Bradley", 5);
        school.Add("Jeff", 1);
        school.Add("Jeff", 2);

        var actual = school.Grade(1);

        var expected = new[] { "Jeff", "Bradley", "Franklin" };

        Assert.Equal(expected, actual);
    }
예제 #8
0
    public void Student_names_with_grades_are_displayed_in_the_same_sorted_roster()
    {
        var school = new School();

        school.Add("Jennifer", 4);
        school.Add("Kareem", 6);
        school.Add("Christopher", 4);
        school.Add("Kyle", 3);

        var actual = school.Roster();


        var expected = new[] { "Christopher", "Jennifer", "Kareem", "Kyle" };

        Assert.Equal(expected, actual);
    }
예제 #9
0
        public void GivenExistingSchoolGroupName_WhenGetByName_ThenReturnIt()
        {
            SchoolGroup firstClass = new SchoolGroup("A");

            School school = new School();

            school.Add(firstClass);

            Assert.AreEqual(firstClass, school.GetByName("A"));
        }
예제 #10
0
        public void GivenNonExistingSchoolGroupName_WhenGetByName_ThenReturnNull()
        {
            SchoolGroup firstClass = new SchoolGroup("A");

            School school = new School();

            school.Add(firstClass);

            Assert.IsNull(school.GetByName("B"));
        }
예제 #11
0
        public void GivenExistingSchoolGroupName_WhenRemove_ThenRemoveAndTrue()
        {
            SchoolGroup sc     = new SchoolGroup("A");
            School      school = new School();

            school.Add(sc);
            bool result = school.Remove("A");

            CollectionAssert.DoesNotContain(new List <SchoolGroup>(school.GetAllSchoolGroups()), sc);
            Assert.IsTrue(result);
        }
예제 #12
0
    public void Adding_a_student_adds_them_to_the_sorted_roster()
    {
        var school = new School();

        school.Add("Aimee", 2);

        var actual = school.Roster();

        var expected = new[] { "Aimee" };

        Assert.Equal(expected, actual);
    }
예제 #13
0
 public void Test_SchoolWithValidCourse()
 {
     try
     {
         var course = new Course();
         var school = new School();
         school.Add(course);
     }
     catch (Exception ex)
     {
         Assert.Fail("Expected no exception, but got: " + ex.Message);
     }
 }
예제 #14
0
파일: frmSchool.cs 프로젝트: jmkasun/YBS
        private void addbtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateBeforeAdd())
                {
                    using (School sc = new School(true))
                    {
                        sc.Name = nameTextBoxX.Text;

                        if (occuID == 0)
                        {
                            if (sc.Add() == 1)
                            {
                                MessageView.ShowMsg("Sucessfully Added");

                                //errorProvider1.SetError(idTxt, string.Empty);
                                //errorProvider1.SetError(nameTxt, string.Empty);

                                clear();
                            }
                        }
                        else
                        {
                            sc.ID = occuID;

                            if (MessageView.ShowQuestionMsg("Update School") == DialogResult.OK)
                            {
                                if (sc.Update() == 1)
                                {
                                    MessageView.ShowMsg("Sucessfully Updated");

                                    //errorProvider1.SetError(idTxt, string.Empty);
                                    //errorProvider1.SetError(nameTxt, string.Empty);

                                    clear();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageView.ShowErrorMsg(ex.Message);
            }
        }
예제 #15
0
    public void Student_names_with_grades_are_displayed_in_the_same_sorted_roster()
    {
        var school = new School();

        school.Add("Peter", 2);
        school.Add("Anna", 1);
        school.Add("Barb", 1);
        school.Add("Zoe", 2);
        school.Add("Alex", 2);
        school.Add("Jim", 3);
        school.Add("Charlie", 1);

        var actual = school.Roster();

        var expected = new[] { "Anna", "Barb", "Charlie", "Alex", "Peter", "Zoe", "Jim" };

        Assert.Equal(expected, actual);
    }
예제 #16
0
        private static School ReadStudentsFromFile(string path)
        {
            var school = new School();

            using (var reader = new StreamReader(path))
            {
                var line = reader.ReadLine();

                while (line != null)
                {
                    var currentLine = line.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    var student = new Student(currentLine[0].Trim(), currentLine[1].Trim(), currentLine[2].Trim());
                    school.Add(student);

                    line = reader.ReadLine();
                }
            }

            return school;
        }
예제 #17
0
        public Response <SchoolDto> AddSchool(Request <School> request)
        {
            Response <SchoolDto> response = new Response <SchoolDto>()
            {
                Item = null
            };

            if (request == null || request.Item == null)
            {
                // Configure the Error response.
                response.Code = OperationCode.ResponseCode.ERROR;
                response.ErrorList.Add(MessageResource.GetInstance().GetText("SchoolDAL_AddNull", MESSAGE_RESOURCE));
            }
            else if (request.Item.IsValid() && !ExistSchool(request.Item))
            {
                School.Add(request.Item);
                SaveChanges();

                // Configure the Success response.
                response.Item = new SchoolDto()
                {
                    SchoolId = request.Item.SchoolId,
                    Name     = request.Item.Name,
                    City     = request.Item.City,
                    Phone    = request.Item.Phone,
                    Email    = request.Item.Email
                };
                response.Code = OperationCode.ResponseCode.SUCCESS;
                response.MessageList.Add(MessageResource.GetInstance().GetText("SchoolDAL_AddSuccess", MESSAGE_RESOURCE));
            }
            else
            {
                // Configure the Error response.
                response.Code = OperationCode.ResponseCode.ERROR;
                response.ErrorList.Add(MessageResource.GetInstance().GetText("SchoolDAL_AddInvalid", MESSAGE_RESOURCE));
            }

            return(response);
        }
예제 #18
0
    public void Adding_a_student_adds_them_to_the_roster_for_the_given_grade()
    {
        school.Add("Aimee", 2);
        var expected = new [] { "Aimee" };

        Assert.Equal(expected, school.Roster(2));
    }
예제 #19
0
    public void Adding_a_student_adds_them_to_the_roster_for_the_given_grade()
    {
        school.Add("Aimee", 2);
        var expected = new List <string> {
            "Aimee"
        };

        Assert.That(school.Roster[2], Is.EqualTo(expected));
    }