Created
August 29, 2020 14:41
-
-
Save tsvayer/e3ed7aef667e3d736ea161f85714c825 to your computer and use it in GitHub Desktop.
Veli Extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class VeliExtensions | |
| { | |
| public static IEnumerable<T> ToListTakeWhile<T>(this IEnumerable<T> source, Predicate<T> predicate) | |
| { | |
| return source.TakeWhile(item => !predicate(item)); | |
| } | |
| } | |
| public class VeliExtensionTests | |
| { | |
| [Test] | |
| public void RedundantExtension() | |
| { | |
| var data = new[] {"Ali", "Mehmet", "Veli", "Vitaliy"}; | |
| var defaultExtension = data.TakeWhile(i => i != "Veli"); | |
| var veliExtension = data.ToListTakeWhile(i => i == "Veli"); | |
| Assert.That(defaultExtension, Is.EqualTo(veliExtension)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment