This file contains 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
class Foo | |
{ | |
List<Person> _people = new List<Person>(); | |
IEnumerable<Person> Drinkers() | |
{ | |
return people.Where(p => p.Age >= 18); | |
} | |
IEnumerable<Person> Drinkers2() | |
{ |
This file contains 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
// http://devlicio.us/blogs/derik_whittaker/archive/2012/10/20/how-to-split-a-list-into-chunks-fun-code.aspx | |
static class GroupingExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> GroupByCount<T>(this IEnumerable<T> source, int count) | |
{ | |
if (source == null) throw new ArgumentNullException("source"); | |
return GroupByCountIterator<T>(source, count); | |
} |
This file contains 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
using System; | |
using System.Collections; | |
using System.Data; | |
namespace TestDataTableBuilder | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains 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 ClassToBeTested | |
{ | |
public static void DoSomething(int input, AnotherCrazyPublicStaticClass staticClass) | |
{ | |
var result = staticClass.MethodToBeMocked(input); // go hit the database, network, web services, file and everything else you can imagine. | |
// now some business logic that I want to test | |
// 400 lines of code | |
// if result is blah do x otherwise do y | |
// 20 foreach loops each one with 2 nested loops and 10 if conditions. | |
} |
This file contains 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 class MainViewModel : ViewModelBase | |
{ | |
public MainViewModel() | |
{ | |
ActivityProcessor processor = new ActivityProcessor(); | |
GetUnicornsCommand = processor.CreateCommand(GetUnicorns).WithContinuation(HandleGetUnicornErrors); | |
} | |
IEnumerable<IActivity> GetUnicorns() | |
{ |
This file contains 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
private static IEnumerable<TSource> SkipWhileImpl<TSource>( | |
IEnumerable<TSource> source, | |
Func<TSource, bool> predicate) | |
{ | |
using (IEnumerator<TSource> iterator = source.GetEnumerator()) | |
{ | |
do | |
{ | |
if (!iterator.MoveNext()) | |
yield break; |
This file contains 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 class TestController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
return View("Index").WithStatus("Some message"); | |
} | |
} | |
public static class StatusResultExtensions | |
{ |
NewerOlder