public void TestDefaultIfEmpty_not_data() { var defaultInput = new Employee { Name = "Cash" }; var expected = new List <Employee> { defaultInput }; var younger = RepositoryFactory.GetEmployees().Where(a => a.Age <= 15); expected.ToExpectedObject().ShouldEqual(WithoutLinq.CashDefaultIfEmpty(younger, defaultInput).ToList()); expected.ToExpectedObject().ShouldEqual(younger.CashDefaultIfEmpty(defaultInput).ToList()); }
public void TestDefaultIfEmpty_have_data() { var defaultInput = new Employee { Name = "Cash" }; var expected = 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 }, }; var younger = RepositoryFactory.GetEmployees().Where(a => a.Age > 40); expected.ToExpectedObject().ShouldEqual(WithoutLinq.CashDefaultIfEmpty(younger, defaultInput).ToList()); expected.ToExpectedObject().ShouldEqual(younger.CashDefaultIfEmpty(defaultInput).ToList()); }