Beispiel #1
0
        public void two_employee_are_equal_test()
        {
            var firstEmployees = new List <Employee>
            {
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Tom", Role = RoleType.Engineer, MonthSalary = 140, Age = 33, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Kevin", Role = RoleType.Manager, MonthSalary = 380, Age = 55, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Andy", Role = RoleType.OP, MonthSalary = 80, Age = 22, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Bas", Role = RoleType.Engineer, MonthSalary = 280, Age = 36, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Mary", Role = RoleType.OP, MonthSalary = 180, Age = 26, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Frank", Role = RoleType.Engineer, MonthSalary = 120, Age = 16, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joey", Role = RoleType.Engineer, MonthSalary = 250, Age = 40, WorkingYear = 2.6
                },
            };
            var secondEmployee = RepositoryFactory.GetEmployees();

            Assert.IsTrue(YourOwnLinq.IsSameEmployee(firstEmployees, secondEmployee, new ChloeEmployeeCompare()));
        }
Beispiel #2
0
        public void skip_3_while_salary_lower_150()
        {
            var employee = RepositoryFactory.GetEmployees();
            var actual   = YourOwnLinq.SkipWhile(employee, 3, e => e.MonthSalary < 150);

            var expected = new List <Employee>()
            {
                new Employee {
                    Name = "Kevin", Role = RoleType.Manager, MonthSalary = 380, Age = 55, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Bas", Role = RoleType.Engineer, MonthSalary = 280, Age = 36, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Mary", Role = RoleType.OP, MonthSalary = 180, Age = 26, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Frank", Role = RoleType.Engineer, MonthSalary = 120, Age = 16, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joey", Role = RoleType.Engineer, MonthSalary = 250, Age = 40, WorkingYear = 2.6
                },
            };

            expected.ToExpectedObject().ShouldEqual(actual.ToList());
        }
Beispiel #3
0
        public void SequenceEqualPlusOne()
        {
            var employees         = RepositoryFactory.GetEmployees();
            var validateEmployees = new List <Employee>
            {
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Tom", Role = RoleType.Engineer, MonthSalary = 140, Age = 33, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Kevin", Role = RoleType.Manager, MonthSalary = 380, Age = 55, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Andy", Role = RoleType.OP, MonthSalary = 80, Age = 22, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Bas", Role = RoleType.Engineer, MonthSalary = 280, Age = 36, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Mary", Role = RoleType.OP, MonthSalary = 180, Age = 26, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Frank", Role = RoleType.Engineer, MonthSalary = 120, Age = 16, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joey", Role = RoleType.Engineer, MonthSalary = 250, Age = 40, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joey", Role = RoleType.Engineer, MonthSalary = 250, Age = 40, WorkingYear = 2.6
                },
            };
            var act = YourOwnLinq.YourSequenceEqual(employees, validateEmployees, new myCompare());

            Assert.AreEqual(false, act);
        }
Beispiel #4
0
        public void Distinct()
        {
            var employees = RepositoryFactory.GetEmployees();

            var act = YourOwnLinq.YourDistinct(employees, new myCompare());
            var exp = employees.Distinct();

            exp.ToExpectedObject().ShouldEqual(act.ToList());
        }
Beispiel #5
0
        public void Contains()
        {
            var employees         = RepositoryFactory.GetEmployees();
            var validateEmployees = RepositoryFactory.GetEmployees();
            var act = YourOwnLinq.YourContains(employees, validateEmployees, new myCompare());

            Assert.AreEqual(true, act);

            Console.Write(Enumerable.Repeat("a", 10));
        }
Beispiel #6
0
        public void contains_special_ball_purple_test()
        {
            var colorBalls = RepositoryFactory.GetBalls();
            var colorBall  = new ColorBall {
                Color = Color.Purple, Prize = 500
            };
            var actul = YourOwnLinq.IsSameBall(colorBalls, colorBall, new ChloeBallCompare());

            Assert.IsTrue(actul);
        }
Beispiel #7
0
        public void cal_salary()
        {
            var employees = RepositoryFactory.GetEmployees();
            var actual    = YourOwnLinq.GetSumSalary(employees, 3, x => x.MonthSalary);
            var expected  = new List <int>()
            {
                620,
                540,
                370
            };

            expected.ToExpectedObject().ShouldEqual(actual.ToList());
        }
Beispiel #8
0
        public void Add91PortTest()
        {
            var urls = RepositoryFactory.GetUrls();

            var actual   = YourOwnLinq.Append91Port(urls);
            var expected = new string[]
            {
                "http://tw.yahoo.com:91",
                "https://facebook.com",
                "https://twitter.com:91",
                "http://github.com"
            };

            expected.ToExpectedObject().ShouldEqual(actual.ToArray());
        }
Beispiel #9
0
        public void take_top_2_employee_salary_over_150()
        {
            var employees = RepositoryFactory.GetEmployees();
            var actual    =
                YourOwnLinq.GetSalaryOverSettingByNumber(employees, employee => employee.MonthSalary > 150, 2);
            var expected = new List <Employee>()
            {
                new Employee {
                    Name = "Kevin", Role = RoleType.Manager, MonthSalary = 380, Age = 55, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Bas", Role = RoleType.Engineer, MonthSalary = 280, Age = 36, WorkingYear = 2.6
                }
            };

            expected.ToExpectedObject().ShouldEqual(actual.ToList());
        }
Beispiel #10
0
        public void two_employee_not_equal_test()
        {
            var firstEmployees = new List <Employee>
            {
                new Employee {
                    Name = "Joe", Role = RoleType.Engineer, MonthSalary = 100, Age = 44, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Kevin", Role = RoleType.Manager, MonthSalary = 380, Age = 55, WorkingYear = 2.6
                },
                new Employee {
                    Name = "Joey", Role = RoleType.Engineer, MonthSalary = 250, Age = 40, WorkingYear = 2.6
                },
            };
            var secondEmployee = RepositoryFactory.GetEmployees();

            Assert.IsFalse(YourOwnLinq.IsSameEmployee(firstEmployees, secondEmployee, new ChloeEmployeeCompare()));
        }
Beispiel #11
0
 public void Single()
 {
     var employees = RepositoryFactory.GetEmployees();
     var result    = YourOwnLinq.YourSingle(employees, x => x.Role == RoleType.OP);
 }