public void ObservableDictionaryExtensions_CountWithPredicate_ReturnsCorrectSize()
        {
            var dictionary = new ObservableDictionary <Int32, String>()
            {
                { 1, "A" },
                { 2, "B" },
                { 3, "C" },
            };

            var result = dictionary.Count(x => x.Key % 2 == 0);

            TheResultingValue(result).ShouldBe(1);
        }
Esempio n. 2
0
        /// <summary>
        /// Gather all the courses a specific teacher teaches
        /// </summary>
        /// <param name="teacher">The teacher to use</param>
        private void GatherTeacherCourses(Teacher teacher)
        {
            // Reset the Courses collection to fit the current teacher
            Courses = new ObservableDictionary <int, string>(TeacherCoursesHandler.GetTeacherCoursesNames(teacher, true));

            // Automatically select a course if possible
            if (Courses.Count() > 0)
            {
                SelectedCourse = Courses.First().Key;
            }
            else
            {
                SelectedCourse = NOT_ASSIGNED;
            }

            // For some reason the selections are not updated properly in the view unless called again
            OnPropertyChanged("SelectedCourse");
        }
        public void ObservableDictionaryExtensions_Count_ReturnsCorrectSize()
        {
            var dictionary = new ObservableDictionary<Int32, String>()
            {
                { 1, "A" },
                { 2, "B" },
                { 3, "C" },
            };

            var result = dictionary.Count();

            TheResultingValue(result).ShouldBe(3);
        }