public void TestSingleOrDefault_not_data() { var employees = RepositoryFactory.GetEmployees(); Assert.Null(WithoutLinq.CashSingleOrDefault(employees, a => a.Role == RoleType.Unknown)); Assert.Null(employees.CashSingleOrDefault(a => a.Role == RoleType.Unknown)); }
public void TestAllisTrue() { var employees = RepositoryFactory.GetEmployees(); Assert.True(WithoutLinq.CashAll(employees, a => a.MonthSalary > 0)); Assert.True(employees.CashAll(a => a.MonthSalary > 0)); }
public void TestSingleOrDefault_more_then_one_data() { var employees = RepositoryFactory.GetEmployees(); Assert.Null(WithoutLinq.CashSingleOrDefault(employees, a => a.Role == RoleType.Engineer)); Assert.Null(employees.CashSingleOrDefault(a => a.Role == RoleType.Engineer)); }
public void SequenceEquals_Test() { var employees = RepositoryFactory.GetEmployees(); var anotherEmployees = RepositoryFactory.GetAnotherEmployees(); Assert.IsFalse(WithoutLinq.mySequenceEqual(employees, anotherEmployees, new MyCompare())); }
public void SkipWhile() { var employees = RepositoryFactory.GetEmployees(); var actual = WithoutLinq.SkipWhile(employees, 3, employee => employee.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()); }
public void TestSinge() { var employees = RepositoryFactory.GetEmployees(); Assert.Equal(RoleType.Manager, WithoutLinq.CashSingle(employees, a => a.Role == RoleType.Manager).Role); Assert.Equal(RoleType.Manager, employees.CashSingle(a => a.Role == RoleType.Manager).Role); }
public void TestAny_not_any_condition() { var employees = RepositoryFactory.GetEmployees(); Assert.True(WithoutLinq.CashAny(employees)); Assert.True(employees.CashAny()); }
public void TestAny() { var employees = RepositoryFactory.GetEmployees(); Assert.False(WithoutLinq.CashAny(employees, a => a.MonthSalary > 500)); Assert.False(employees.CashAny(a => a.MonthSalary > 500)); }
public void TestSingle_not_data() { var employees = RepositoryFactory.GetEmployees(); Assert.Throws <InvalidOperationException>(() => WithoutLinq.CashSingle(employees, a => a.Role == RoleType.Unknown)); Assert.Throws <InvalidOperationException>(() => employees.CashSingle(a => a.Role == RoleType.Unknown)); }
public void TestSequence_equal() { var products = RepositoryFactory.GetProducts(); var anotherProducts = RepositoryFactory.GetProducts(); Assert.True(WithoutLinq.CashSequence(products, anotherProducts, new MyCompareProduct())); Assert.True(products.CashSequence(anotherProducts, new MyCompareProduct())); }
public void Paging_GetSum() { var employees = RepositoryFactory.GetEmployees(); var act = WithoutLinq.GetSum(employees, 3, x => x.MonthSalary); var expected = new int[] { 620, 540, 370 }; expected.ToExpectedObject().ShouldEqual(act.ToArray()); }
public void TestSingle_more_then_one_data() { var employees = RepositoryFactory.GetEmployees(); Assert.Throws <InvalidOperationException>(() => WithoutLinq.CashSingle(employees, a => a.Role == RoleType.Engineer)); Assert.Throws <InvalidOperationException>(() => employees.CashSingle(a => a.Role == RoleType.Engineer)); }
public void TestSequence_item_have_one_not_equal() { var products = RepositoryFactory.GetProducts(); var anotherProducts = RepositoryFactory.GetAnotherProducts(); Assert.False(WithoutLinq.CashSequence(products, anotherProducts, new MyCompareProduct())); Assert.False(products.CashSequence(anotherProducts, new MyCompareProduct())); }
public void TestSequence_source_more_than_one() { var products = RepositoryFactory.GetProductsS(); var anotherProducts = RepositoryFactory.GetProducts(); Assert.False(WithoutLinq.CashSequence(products, anotherProducts, new MyCompareProduct())); Assert.False(products.CashSequence(anotherProducts, new MyCompareProduct())); }
public void TestContains_not_item() { var products = RepositoryFactory.GetProducts(); var product = new Product(); Assert.False(WithoutLinq.CashContain(products, product, new MyCompareProduct())); Assert.False(products.CashContain(product, new MyCompareProduct())); }
public void TestFirstOrDefault() { var employees = RepositoryFactory.GetEmployees(); Assert.Equal("Kevin", WithoutLinq.CashFirstOrDefault(employees, a => a.MonthSalary > 200).Name); Assert.Null(WithoutLinq.CashFirstOrDefault(employees, a => a.MonthSalary > 500)); Assert.Equal("Kevin", employees.CashFirstOrDefault(a => a.MonthSalary > 200).Name); Assert.Null(employees.CashFirstOrDefault(a => a.MonthSalary > 500)); }
public void DefaultIfEmpty_Test() { var employees = RepositoryFactory.GetEmployees(); var youngers = WithoutLinq.myDefaultEmpty(employees.Where(e => e.Age <= 15)); var emptyEmployees = Enumerable.Empty <Employee>(); emptyEmployees.ToExpectedObject().ShouldEqual(youngers.ToList()); }
public void TestFirst() { var employees = RepositoryFactory.GetEmployees(); Assert.Equal("Kevin", WithoutLinq.CashFirst(employees, a => a.MonthSalary > 200).Name); Assert.Throws <ArgumentNullException>(() => WithoutLinq.CashFirst(employees, a => a.MonthSalary > 500)); Assert.Equal("Kevin", employees.CashFirst(a => a.MonthSalary > 200).Name); Assert.Throws <ArgumentNullException>(() => employees.CashFirst(a => a.MonthSalary > 500)); }
public void find_products_that_price_between_200_and_500() { var products = RepositoryFactory.GetProducts(); var actual = WithoutLinq.FindProductByPrice(products, 200, 500); var expected = new List <Product>() { //todo }; expected.ToExpectedObject().ShouldEqual(actual); }
public void sum_monthsalary() { var employees = RepositoryFactory.GetEmployees(); var actual = WithoutLinq.CashSum(employees, 3); var expected = new List <int>() { 620, 540, 370 }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void ToHttps() { var urls = RepositoryFactory.GetUrls(); IEnumerable <string> actual = WithoutLinq.ToHttps(urls); var expected = new List <string> { "https://tw.yahoo.com", "https://facebook.com", "https://twitter.com", "https://github.com", }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void Group() { var employees = RepositoryFactory.GetEmployees(); var actual = WithoutLinq.JasonGroupBy(employees, 3, employee => employee.MonthSalary); var expected = new List <int>() { 620, 540, 370 }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void http_convert_to_https() { var urls = RepositoryFactory.GetUrls(); var actual = WithoutLinq.CovertHttpToHttps(urls); var expected = new List <string>() { "https://tw.yahoo.com", "https://facebook.com", "https://twitter.com", "https://github.com" }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void GetUrlLength() { var urls = RepositoryFactory.GetUrls(); IEnumerable <int> httpsUrls = WithoutLinq.GetUrlsLength(urls, url => url.Length); var expected = new List <int>() { 19, 20, 19, 17 }; expected.ToExpectedObject().ShouldEqual(httpsUrls.ToList()); }
public void changeHttpToHttps() { var urls = RepositoryFactory.GetUrls(); var httpsUrls = WithoutLinq.ToHttps(urls); var expected = new List <string>() { "https://tw.yahoo.com", "https://facebook.com", "https://twitter.com", "https://github.com" }; expected.ToExpectedObject().ShouldEqual(httpsUrls.ToList()); }
public void url_length() { var urls = RepositoryFactory.GetUrls(); IEnumerable <int> actual = WithoutLinq.Map(urls, url => url.Length); var expected = new List <int>() { 19, 20, 19, 17 }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void find_urls_should_return_startwith_https() { var urls = RepositoryFactory.GetUrls(); var actual = WithoutLinq.Tohttps(urls); var expected = new List <string>() { "https://tw.yahoo.com", "https://facebook.com", "https://twitter.com", "https://github.com", }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void find_urls_should_return_url_length() { var urls = RepositoryFactory.GetUrls(); var actual = WithoutLinq.GetUrlLength(urls); var expected = new List <int>() { 19, 20, 19, 17, }; expected.ToExpectedObject().ShouldEqual(actual.ToList()); }
public void Take() { var employees = RepositoryFactory.GetEmployees(); var act = WithoutLinq.JoeyTake(employees, 2); var expected = 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 }, }; expected.ToExpectedObject().ShouldEqual(act.ToList()); }
public void TakeWhile() { var employees = RepositoryFactory.GetEmployees(); var act = WithoutLinq.TakeWhile(employees, 2, x => x.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 }, }; expected.ToExpectedObject().ShouldEqual(act.ToList()); }