public void DoAnyActiveCohortsHave3JuniorInstructors()
        {
            //var doAny = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAny = PracticeData.Any(cohort => cohort.JuniorInstructors.Count() == 3);

            Assert.IsTrue(doAny); //<-- change false to doAny
        }
        public void DoAnyCohortsHavePrimaryInstructorsBornIn1980s()
        {
            //var doAny = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAny = PracticeData.Any(cohort => cohort.PrimaryInstructor.Birthday.Year >= 1980 & cohort.PrimaryInstructor.Birthday.Year >= 1989);

            Assert.IsTrue(doAny); //<-- change false to doAny
        }
        public void AreAnyCohortsBothFullTimeAndNotActive()
        {
            //var doAny = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAny = PracticeData.Any(cohort => cohort.FullTime == true && cohort.Active == false);

            Assert.IsTrue(doAny); //<-- change false to doAny
        }
예제 #4
0
        public void GetFirstCohortWith2JuniorInstructors()
        {
            //var ActualCohort = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var ActualCohort = PracticeData.First(Cohort => Cohort.JuniorInstructors.Count() == 2);

            Assert.AreEqual(ActualCohort, CohortBuilder.Cohort1);
        }
예제 #5
0
        public void GetAllStudents()
        {
            //var expected = PracticeData/*FILL IN LINQ EXPRESSION*/.ToList();
            var expected = PracticeData.SelectMany(c => c.Students).ToList();

            CollectionAssert.AreEqual(expected,
                                      new List <Student> {
                CohortBuilder.Student1,
                CohortBuilder.Student2,
                CohortBuilder.Student3,
                CohortBuilder.Student4,
                CohortBuilder.Student5,
                CohortBuilder.Student6,
                CohortBuilder.Student7,
                CohortBuilder.Student8,
                CohortBuilder.Student9,
                CohortBuilder.Student10,
                CohortBuilder.Student11,
                CohortBuilder.Student12,
                CohortBuilder.Student13,
                CohortBuilder.Student14,
                CohortBuilder.Student15,
                CohortBuilder.Student16,
                CohortBuilder.Student17,
                CohortBuilder.Student18,
                CohortBuilder.Student19,
                CohortBuilder.Student20
            });
        }
예제 #6
0
        public List <PracticeData> GetPractices(string userName)
        {
            var list = new List <PracticeData>();

            if (!File.Exists(XML_FILE_PATH))
            {
                return(list);
            }
            try {
                var doc           = XDocument.Load(XML_FILE_PATH);
                var userNode      = doc.Root.Elements().FirstOrDefault(a => a.Attribute("name").Value == userName);
                var practisesNode = userNode.Element("practises");
                foreach (var pra in practisesNode.Elements())
                {
                    var pr = new PracticeData()
                    {
                        Book             = pra.Attribute("book").Value,
                        Modules          = pra.Attribute("modules").Value,
                        DateTime         = Convert.ToDateTime(pra.Attribute("date").Value),
                        WordsCount       = Convert.ToInt32(pra.Attribute("count").Value),
                        ErrorWordsCount  = Convert.ToInt32(pra.Attribute("error").Value),
                        Seconds          = Convert.ToInt32(pra.Attribute("seconds").Value),
                        User             = userName,
                        WordsCountMinute = Convert.ToSingle(pra.Attribute("wordsCountMinute").Value)
                    };
                    list.Add(pr);
                }
            }
            catch (Exception e) {
            }

            return(list);
        }
        public void HowManyJuniorInstructorsAreThereInTheCohortWithTheMostJuniorInstructors()
        {
            //var maxValue = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var maxValue = PracticeData.Max(cohort => cohort.JuniorInstructors.Count());

            Assert.AreEqual(maxValue, 3);
        }
        public void GetOnlyCohortWithThreeJuniorInstructors()
        {
            //var ActualCohort = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var ActualCohort = PracticeData.Single(cohort => cohort.JuniorInstructors.Count() == 3);

            Assert.AreEqual(ActualCohort, CohortBuilder.Cohort3);
        }
예제 #9
0
        public void DoAllActiveCohortsHavePrimaryInstructorsWithFirstNamesThatContainTheLetterA()
        {
            var doAll = PracticeData.All(c => c.Active == true && c.PrimaryInstructor.FirstName.Contains('a')); /*FILL IN LINQ EXPRESSION*/;

            Console.WriteLine(doAll);
            Assert.IsFalse(doAll); //<-- change false to doAll
        }
예제 #10
0
        public void GetFirstCohortWherePrimaryInstructorIsKate()
        {
            //var ActualCohort = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var ActualCohort = PracticeData.First(Cohort => Cohort.PrimaryInstructor.FirstName == "Kate");

            Assert.AreEqual(ActualCohort, CohortBuilder.Cohort4);
        }
예제 #11
0
        public void GetYoungestStudent()
        {
            //var student = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var student = PracticeData.SelectMany(c => c.Students).OrderByDescending(s => s.Birthday).First();

            Assert.AreEqual(student, CohortBuilder.Student3);
        }
        public void GetOnlyCohortWithInstructorNamedZeldaOrNull()
        {
            //var ActualCohort = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var ActualCohort = PracticeData.SingleOrDefault(cohort => cohort.PrimaryInstructor.FirstName == "Zelda");

            Assert.IsNull(ActualCohort);
        }
예제 #13
0
        public void DoAllCohortsHaveActivePrimaryInstructors()
        {
            //var doAll = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAll = PracticeData.All(cohort => cohort.PrimaryInstructor.Active == true);

            Assert.IsTrue(doAll); //<-- change true to doAll
        }
예제 #14
0
        public void DoAllActiveCohortsHavePrimaryInstructorsWithFirstNamesThatContainTheLetterA()
        {
            //var doAll = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAll = PracticeData.All(cohort => cohort.Active == true && cohort.PrimaryInstructor.FirstName.Contains("A"));

            Assert.IsFalse(doAll); //<-- change false to doAll
        }
예제 #15
0
        public void DoAllCohortsHavePrimaryInstructorsBornIn1980s()
        {
            //var doAll = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAll = PracticeData.All(cohort => cohort.PrimaryInstructor.Birthday.Year < 1979 && cohort.PrimaryInstructor.Birthday.Year > 1990);

            Assert.IsFalse(doAll); //<-- change true to doAll
        }
예제 #16
0
        public void DoAllCohortsFiveStudents()
        {
            //var doAll = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAll = PracticeData.All(cohort => cohort.Students.Count() == 5);

            Assert.IsTrue(doAll); //<-- change false to doAll
        }
예제 #17
0
        public void DoAllCohortsHaveTwoOrMoreJuniorInstructors()
        {
            //var doAll = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var doAll = PracticeData.All(cohort => cohort.JuniorInstructors.Count() >= 2);

            Assert.IsTrue(doAll); //<-- change false to doAll
        }
예제 #18
0
 void Show(ActorBaseTag tag, ulong y, bool da)
 {
     if (tag == ActorBaseTag.HighFlyUpRes || tag == ActorBaseTag.LowFlyUpRes)
     {
         curData = GameCenter.practiceMng.data;
         if (curData == null)
         {
             return;
         }
         dustLab.text  = curData.MainData.HighFlyUpRes.ToString();
         reikiLab.text = curData.MainData.LowFlyUpRes.ToString();
         if (yunGong.activeSelf)
         {
             master.IsGray   = UISpriteEx.ColorGray.normal;
             fairy.IsGray    = UISpriteEx.ColorGray.normal;
             coinLab.text    = curData.CoinYG.ToString();
             coinTime.text   = curData.coinTime + "/" + 10;
             diamondLab.text = curData.DiamondYG.ToString();
             if (curData.GetTenTimesYgDiamond() == 0)
             {
                 tenTimesMoney.text = "0";
                 tenTimesEx.IsGray  = UISpriteEx.ColorGray.Gray;
             }
             else
             {
                 tenTimesMoney.text = curData.GetTenTimesYgDiamond().ToString();
                 tenTimesEx.IsGray  = UISpriteEx.ColorGray.normal;
             }
         }
     }
 }
        public void GetOnlyCohortThatIsFullTimeAndPrimaryInstructorBirthdayInTheFuture()
        {
            //var ActualCohort = PracticeData/*FILL IN LINQ EXPRESSION*/;
            var ActualCohort = PracticeData.Single(cohort => cohort.FullTime == true & cohort.PrimaryInstructor.Birthday > DateTime.Now);

            Assert.AreEqual(ActualCohort, CohortBuilder.Cohort2);
        }
        public void GetAllInactiveStudentsByLastName()
        {
            var ActualStudents = PracticeData.SelectMany(cohort => cohort.Students).Where(student => student.Active == false).OrderBy(student => student.LastName).ToList();

            CollectionAssert.AreEqual(ActualStudents, new List <Student> {
                CohortBuilder.Student2, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student17
            });
        }
        public void GetAllCohortsWhereFullTimeIsFalseAndAllInstructorsAreActive()
        {
            var ActualCohorts = PracticeData.Where(cohort => (cohort.FullTime == false) && (cohort.PrimaryInstructor.Active == true) && (cohort.JuniorInstructors.All(jrInstructor => jrInstructor.Active == true))).ToList();

            CollectionAssert.AreEqual(ActualCohorts, new List <Cohort> {
                CohortBuilder.Cohort1
            });
        }
        public void GetAllCohortsWhereAStudentOrInstructorFirstNameIsKate()
        {
            var ActualCohorts = PracticeData.Where(cohort => (cohort.Students.Any(student => student.FirstName == "Kate")) || (cohort.JuniorInstructors.Any(jrInstructor => jrInstructor.FirstName == "Kate")) || (cohort.PrimaryInstructor.FirstName == "Kate")).ToList();

            CollectionAssert.AreEqual(ActualCohorts, new List <Cohort> {
                CohortBuilder.Cohort1, CohortBuilder.Cohort3, CohortBuilder.Cohort4
            });
        }
        public void GetAllCohortsByName()
        {
            var expected = PracticeData.OrderBy(cohort => cohort.Name) /*FILL IN LINQ EXPRESSION*/.ToList();

            CollectionAssert.AreEqual(expected, new List <Cohort> {
                CohortBuilder.Cohort2, CohortBuilder.Cohort4, CohortBuilder.Cohort1, CohortBuilder.Cohort3
            });
        }
        public void GetAllCohortsWithZacharyZohanAsPrimaryOrJuniorInstructor()
        {
            var ActualCohorts = PracticeData.Where(cohort => cohort.PrimaryInstructor.LastName == "Zohan" || cohort.JuniorInstructors.Any(jrInstructor => jrInstructor.LastName == "Zohan")).ToList();

            CollectionAssert.AreEqual(ActualCohorts, new List <Cohort> {
                CohortBuilder.Cohort2, CohortBuilder.Cohort3
            });
        }
예제 #25
0
        public void GetAllStudentsInCohort1ByBirthdayYoungestFirst()
        {
            var expected = PracticeData /*FILL IN LINQ EXPRESSION*/.ToList(); //HINT: Cohort1 is PracticeData[0]

            CollectionAssert.AreEqual(expected, new List <Student> {
                CohortBuilder.Student3, CohortBuilder.Student2, CohortBuilder.Student4, CohortBuilder.Student1, CohortBuilder.Student5
            });
        }
예제 #26
0
        public void GetAllJuniorInstructorsInCohort3ByLastName()
        {
            var expected = PracticeData /*FILL IN LINQ EXPRESSION*/.ToList();

            CollectionAssert.AreEqual(expected, new List <Instructor> {
                CohortBuilder.Instructor4, CohortBuilder.Instructor1, CohortBuilder.Instructor6
            });
        }
예제 #27
0
        public void GetAllCohortNames()
        {
            var expected = PracticeData.Select(cohort => cohort.Name).ToList(); /*FILL IN LINQ EXPRESSION*/

            CollectionAssert.AreEqual(expected, new List <string> {
                "Evening Five", "Cohort of the Future", "Evening Ninja Warriors", "Day Backgammon Geeks"
            });
        }
예제 #28
0
        public void GetAllPrimaryInstructorFirstNames()
        {
            var expected = PracticeData.Select(cohort => cohort.PrimaryInstructor.FirstName).ToList(); /*FILL IN LINQ EXPRESSION*/

            CollectionAssert.AreEqual(expected, new List <string> {
                "Jurnell", "Zachary", "Blaise", "Kate"
            });
        }
예제 #29
0
        public void GetAllPrimaryInstructorsInAllCohorts()
        {
            var expected = PracticeData.Select(cohort => cohort.PrimaryInstructor).ToList(); /*FILL IN LINQ EXPRESSION*/

            CollectionAssert.AreEqual(expected, new List <Instructor> {
                CohortBuilder.Instructor2, CohortBuilder.Instructor6, CohortBuilder.Instructor3, CohortBuilder.Instructor1
            });
        }
        public void GetAllCohortsByName()
        {
            var expected = PracticeData.OrderBy(c => c.Name).ToList();

            CollectionAssert.AreEqual(expected, new List <Cohort> {
                CohortBuilder.Cohort2, CohortBuilder.Cohort4, CohortBuilder.Cohort1, CohortBuilder.Cohort3
            });
        }
 /// <summary>
 /// Tries to add a postcode region.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 /// <param name="practicedata">The practice data.</param>
 /// <param name="region">The region.</param>
 public static void TryAdd(
     this ConcurrentDictionary<string, PostcodeRegion> dictionary,
     PracticeData practicedata,
     string region)
 {
     dictionary.TryAdd(
         practicedata.PracticeCode,
         new PostcodeRegion { Postcode = practicedata.Postcode, Region = region });
 }
        protected List<PracticeData> GetPracticeList()
        {
            var practiceData1 = new PracticeData
            {
                PracticeCode = Data.PracticeCode1,
                Postcode = Data.Postcode1
            };

            var practiceData2 = new PracticeData
            {
                PracticeCode = Data.PracticeCode2,
                Postcode = Data.Postcode2
            };

            return new List<PracticeData> { practiceData1, practiceData2 };
        }