public void Linq2_5Test() { Prepare(); Student[] unis = HomeworkLinqQueries.Linq2_5(_unis); Assert.IsTrue(unis.Single().Name.Equals("Siniša Matić")); }
public void Linq22_1Point() { var universities = GetAllCroatianUniversities(); University[] underAverageStudentNumberUniversities = HomeworkLinqQueries.Linq2_2(universities); Assert.AreEqual(4, underAverageStudentNumberUniversities.Length); }
public void Linq2_4Test() { Prepare(); var unis = HomeworkLinqQueries.Linq2_4(_unis); Assert.IsTrue(unis.Count() == 3); }
public void Linq23_2Points() { var universities = GetAllCroatianUniversities(); Student[] getAllStudents = HomeworkLinqQueries.Linq2_3(universities); Assert.AreEqual(31, getAllStudents.Length); }
public void Linq2_2Test() { Prepare(); var unis = HomeworkLinqQueries.Linq2_2(_unis); Assert.IsTrue(unis.Single().Name.Equals("FFZG")); }
public void Linq21_1Point() { var universities = GetAllCroatianUniversities(); University[] maleOnlyUniversities = HomeworkLinqQueries.Linq2_1(universities); Assert.AreEqual(2, maleOnlyUniversities.Length); Assert.IsTrue(maleOnlyUniversities.Any(u => u.Name == "Uni1")); Assert.IsTrue(maleOnlyUniversities.Any(u => u.Name == "Uni6")); }
public void TestLinq2_1() { foreach (var university in HomeworkLinqQueries.Linq2_1(_universityList.ToArray())) { foreach (var student in university.Students) { Assert.AreEqual(Gender.Male, student.Gender); } } }
/* static void Main(string[] args) * { * University FER = new University(); * FER.Name = "FER"; * * Student Ante = new Student("Ante", "0036"); * Ante.Gender = Gender.Male; * Student Bernard = new Student("Bernard", "0035"); * Bernard.Gender = Gender.Male; * Student Ante1 = new Student("Ante", "0036"); * Ante1.Gender = Gender.Male; * Student Stjepan = new Student("Stjepan", "0031"); * Stjepan.Gender = Gender.Male; * * Student[] students = new Student[4]; * * students[0] = Ante; * students[1] = Ante1; * students[2] = Bernard; * students[3] = Stjepan; * * FER.Students = students; * * University FIL = new University(); * FIL.Name = "FIL"; * * Student Ana = new Student("Ana", "3036"); * Ana.Gender = Gender.Female; * Student Bernarda = new Student("Bernarda", "3035"); * Bernarda.Gender = Gender.Female; * Student Stjepana = new Student("Stjepan", "3031"); * Stjepana.Gender = Gender.Male; * Student Ante2 = new Student("Ante", "0036"); * Ante.Gender = Gender.Male; * * Student[] studentsf = new Student[4]; * * studentsf[0] = Ana; * studentsf[3] = Ante2; * studentsf[2] = Bernarda; * studentsf[1] = Stjepan; * * FIL.Students = studentsf; * * University[] Faksovi = {FER, FIL}; * Faksovi[0] = FER; * Faksovi[1] = FIL; * * Student[] s = HomeworkLinqQueries.Linq2_5(Faksovi); * * foreach (Student stu in s) * { * Console.WriteLine(stu.Name + stu.Jmbag); * } * } */ public static void Main(String[] args) { University[] lista = GetAllCroatianUniversities(); Student[] stu = HomeworkLinqQueries.Linq2_5(lista); foreach (Student s in stu) { Console.WriteLine(s.Name + " " + s.Jmbag); } }
public void Linq25_3Points() { var universities = GetAllCroatianUniversities(); Student[] studentsOnMultipleUniversities = HomeworkLinqQueries.Linq2_5(universities); Assert.AreEqual(3, studentsOnMultipleUniversities.Length); Assert.IsTrue(studentsOnMultipleUniversities.Any(s => s.Jmbag == "1")); Assert.IsTrue(studentsOnMultipleUniversities.Any(s => s.Jmbag == "2")); Assert.IsTrue(studentsOnMultipleUniversities.Any(s => s.Jmbag == "4")); }
public void Linq2_1Test() { Student[] students1 = new Student[] { new Student("Ana", "00036", Gender.Female), new Student("Ivan", "222", Gender.Male) }; Student[] students2 = new Student[] { new Student("ttt", "00036", Gender.Male), new Student("Wwww", "3333", Gender.Male) }; Student[] students3 = new Student[] { new Student("ADAWDAWD", "3333334444", Gender.Male), new Student("adadad", "22222222", Gender.Male) }; Student[] students4 = new Student[] { new Student("Fernando", "9999", Gender.Female), new Student("Bruscetoo", "666666", Gender.Female) }; University fer = new University("FER", students3); University ffzg = new University("FFZG", students1); University tvz = new University("TVZ", students2); University fkit = new University("FKIT", students4); University[] universities = new University[] { ffzg, tvz, fer, fkit }; University[] filtered = HomeworkLinqQueries.Linq2_1(universities); University[] expected = new University[] { tvz, fer }; CollectionAssert.AreEqual(expected, filtered); }
public void Linq1Test() { int[] integers = { 1, 3, 3, 4, 2, 2, 2, 3, 3, 4, 5 }; var strings = HomeworkLinqQueries.Linq1(integers); int[] checkInts = { 1, 2, 3, 4, 5, 1, 3, 4, 2, 1 }; for (int i = 0; i < strings.Length; ++i) { Assert.AreEqual(strings[i], $"Broj { checkInts[i] } ponavlja se { checkInts[i + 5] }"); } }
public void Linq2_3Test() { Prepare(); var unis = HomeworkLinqQueries.Linq2_3(_unis); Assert.IsFalse((from stud in (from stud in unis group stud by stud.Jmbag) where stud.Count() > 1 select stud).Any()); }
public void Linq1_1Point() { int[] integers = new[] { 1, 3, 3, 4, 2, 2, 2, 3, 3, 4, 5 }; string[] result = HomeworkLinqQueries.Linq1(integers); Assert.AreEqual("broj 1 ponavlja se 1 puta", result[0].ToLower()); Assert.AreEqual("broj 2 ponavlja se 3 puta", result[1].ToLower()); Assert.AreEqual("broj 3 ponavlja se 4 puta", result[2].ToLower()); Assert.AreEqual("broj 4 ponavlja se 2 puta", result[3].ToLower()); Assert.AreEqual("broj 5 ponavlja se 1 puta", result[4].ToLower()); }
public void TestLinq2_4() { var allFemaleUniversities = _universityList.Where(e => e.Students.All(s => s.Gender == Gender.Female)); var allFemaleStudents = HomeworkLinqQueries.Linq2_3(allFemaleUniversities.ToArray()); var allMaleUniversities = _universityList.Where(e => e.Students.All(s => s.Gender == Gender.Male)); var allMaleStudents = HomeworkLinqQueries.Linq2_3(allMaleUniversities.ToArray()); foreach (var student in HomeworkLinqQueries.Linq2_4(_universityList.ToArray())) { Assert.IsTrue(student.Gender == Gender.Female ? allFemaleStudents.Contains(student) : allMaleStudents.Contains(student)); } }
public void Linq1Test() { int[] integers = new[] { 1, 3, 3, 4, 2, 2, 2, 3, 3, 4, 5 }; string[] expected = new string[] { "Broj 1 ponavlja se 1 puta", "Broj 2 ponavlja se 3 puta", "Broj 3 ponavlja se 4 puta", "Broj 4 ponavlja se 2 puta", "Broj 5 ponavlja se 1 puta" }; CollectionAssert.AreEqual(expected, HomeworkLinqQueries.Linq1(integers)); }
public void Linq24_2Points() { var universities = GetAllCroatianUniversities(); Student[] oneGenderUniversityStudents = HomeworkLinqQueries.Linq2_4(universities); Assert.AreEqual(7, oneGenderUniversityStudents.Length); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "1")); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "2")); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "30")); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "31")); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "32")); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "2")); Assert.IsTrue(oneGenderUniversityStudents.Any(s => s.Jmbag == "3")); }
public void TestLinq2_2() { var countFirst = _universityList[0].Students.Length; var countSecond = _universityList[1].Students.Length; var countThird = _universityList[2].Students.Length; var countFourth = _universityList[3].Students.Length; var countFifth = _universityList[4].Students.Length; var countSixth = _universityList[5].Students.Length; var avg = (countFirst + countSecond + countThird + countFourth + countFifth + countSixth) / 6.0; foreach (var university in HomeworkLinqQueries.Linq2_2(_universityList.ToArray())) { Assert.IsTrue(university.Students.Length <= avg); } }
static void Main(string[] args) { //Console.WriteLine("jurij"); //ITodoRepository repository = new TodoRepository(); //repository.Add(null); ITodoRepository repository = new TodoRepository(); var todoItem = new TodoItem("Running"); repository.Add(todoItem); int[] integers = new[] { 1, 3, 3, 4, 2, 2, 2, 3, 3, 4, 5 }; HomeworkLinqQueries.Linq1(integers); Console.WriteLine("Task 5"); Klasa.Part1(); Klasa.Part2(); Klasa.Part3(); Klasa.Part4(); Klasa.Part5(); Klasa.Part6(); Console.Read(); }
public void Linq2_3Test() { Student ivan = new Student("Ivan", "222", Gender.Male); Student ana = new Student("Ana", "00036", Gender.Female); Student ante = new Student("Ante", "011111", Gender.Male); Student prokop = new Student("Prokop", "3333", Gender.Male); Student zakop = new Student("Zakop", "3333334444", Gender.Male); Student[] students1 = new Student[] { ivan, ana }; Student[] students2 = new Student[] { ivan, ante }; Student[] students3 = new Student[] { ana, prokop }; Student[] students4 = new Student[] { zakop, prokop }; University fer = new University("FER", students3); University ffzg = new University("FFZG", students1); University tvz = new University("TVZ", students2); University fkit = new University("FKIT", students4); University[] universities = new University[] { ffzg, tvz, fer, fkit }; Student[] filtered = HomeworkLinqQueries.Linq2_3(universities); Student[] expected = new Student[] { ivan, ana, ante, zakop, prokop }; CollectionAssert.AreEquivalent(expected, filtered); }
public void TestLinq2_5() { Assert.AreEqual(_studentList.Count, HomeworkLinqQueries.Linq2_5(_universityList.ToArray()).Length); Assert.IsTrue(HomeworkLinqQueries.Linq2_5(_universityList.ToArray()).OrderBy(e => e.Jmbag) .SequenceEqual(_studentList.OrderBy(e => e.Jmbag))); }
public void TestLinq1() { Assert.AreEqual("Broj 1 ponavlja se 1 puta", HomeworkLinqQueries.Linq1(_intArray)[0]); Assert.AreEqual("Broj 3 ponavlja se 4 puta", HomeworkLinqQueries.Linq1(_intArray)[2]); Assert.AreEqual("Broj 5 ponavlja se 1 puta", HomeworkLinqQueries.Linq1(_intArray)[4]); }