public void ShouldTestFilter() { //Arrange IEnumerable <string> src = new string[] { "linha 0", "linha 1", "linha 2", "linha 3" }; IEnumerable <string> expected = new string[] { "linha 3" }; //Act IEnumerable <string> actual = LazyQueries.Filter <string>(src, line => line.Contains("3")); //Assert Assert.IsTrue(AreIEnumerableEqual(expected, actual)); }
public void ShouldTestSplitWithMultipleSepsRemoveEmpties() { string src = "#The Search API\r\n#Data returned is laid out in the following order:-\r\n#AreaName Country Region(If available) Latitude Longitude Population(if available) Weather Forecast URL\r\n#\r\nOporto\tSpain\tGalicia\t42.383\t-7.100\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=42.3833,-7.1\nOporto\tPortugal\tPorto\t41.150\t-8.617\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=41.15,-8.6167\nOporto\tSouth Africa\tLimpopo\t-22.667\t29.633\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=-22.6667,29.6333\nEl Oporto\tMexico\tTamaulipas\t23.266\t-98.768\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=23.2658,-98.7675\nPuerto Oporto\tBolivia\tPando\t-9.933\t-66.417\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=-9.9333,-66.4167\nOporto\tCuba\tSantiago de Cuba\t20.233\t-76.167\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=20.2333,-76.1667\n"; IEnumerable <string> expected = new string [] { "Oporto\tSpain\tGalicia\t42.383\t-7.100\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=42.3833,-7.1", "Oporto\tPortugal\tPorto\t41.150\t-8.617\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=41.15,-8.6167", "Oporto\tSouth Africa\tLimpopo\t-22.667\t29.633\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=-22.6667,29.6333", "El Oporto\tMexico\tTamaulipas\t23.266\t-98.768\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=23.2658,-98.7675", "Puerto Oporto\tBolivia\tPando\t-9.933\t-66.417\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=-9.9333,-66.4167", "Oporto\tCuba\tSantiago de Cuba\t20.233\t-76.167\t0\thttp://api-cdn.worldweatheronline.com/v2/weather.aspx?q=20.2333,-76.1667" }; //Act IEnumerable <string> intermediate = LazyQueries.Split(src, "\r\n", "\r", "\n"); IEnumerable <string> actual = LazyQueries.Filter <string>(LazyQueries.Filter <string>(intermediate, line => !line.Equals("")), line => !line.StartsWith("#")); //Assert Assert.IsTrue(AreIEnumerableEqual(expected, actual)); }