Skip to content

Instantly share code, notes, and snippets.

Simone Busoli simoneb

Block or report user

Report or block simoneb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 1 - Test.cs
[TestFixture]
public class Test : Calculator
{
[Test]
public void No_books_are_0()
{
Assert.AreEqual(0, Price());
}
[Test]
View Foldr.cs
public static class Extensions
{
public static bool And(this IEnumerable<bool> bools)
{
return bools.Foldr(Expression.AndAlso, true);
}
public static T Foldr<T>(this IEnumerable<T> enumerable, Func<Expression, Expression, BinaryExpression> fold, T v)
{
foreach(var b in enumerable)
View costura.xml
<UsingTask
TaskName="Costura.EmbedTask"
AssemblyFile="$(SolutionDir)[path to]\Costura.dll" />
<Target Name="AfterBuild">
<Costura.EmbedTask />
</Target>
View gist:1562857
IEnumerable<string> Anagrams(IEnumerable<char> input)
{
foreach (var c in input)
{
var except = input.Except(new[]{c});
if(except.Any())
foreach (var element in Anagrams(except))
yield return c.ToString() + element;
else
@simoneb
simoneb / gist:2508758
Created Apr 27, 2012
Async IO the simple way
View gist:2508758
using(var c = new WebClient())
{
c.DownloadStringCompleted += (_, r) => Console.WriteLine(r.Result);
c.DownloadStringAsync(new Uri("http://www.google.at"));
}
@simoneb
simoneb / parser.cs
Last active Oct 11, 2015
Simple dynamic command line arguments parser
View parser.cs
class Options : DynamicObject
{
readonly IDictionary<string, object> inner = new ExpandoObject();
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (!inner.TryGetValue(binder.Name, out result))
result = false;
else
result = result != null ? new OptionValue(result.ToString()) : (dynamic)true;
@simoneb
simoneb / linqpad-nunitlite.cs
Created Oct 29, 2012
NUnitLite in LINQPad
View linqpad-nunitlite.cs
void Main()
{
new NUnitLite.Runner.TextUI().Execute(new[]{"-noheader"});
}
// Define other methods and classes here
[Test]
public void SomeTest()
{
Assert.Pass();
View nunit-simple-test.cs
[Test]
public void OneSimpleTest()
{
var eightBall = new EightBall();
var answer = eightBall.ShouldIChangeJob();
Assert.That(answer, Is.True);
}
View nunit-simple-async-test.cs
[Test]
public async void OneSimpleTest()
{
var eightBall = new EightBall();
var answer = await eightBall.ShouldIChangeJob();
Assert.That(answer, Is.True);
// why am I still here?
}
@simoneb
simoneb / nunit-simple-test-workaround.cs
Last active Dec 11, 2015
A simple test - workaround for async
View nunit-simple-test-workaround.cs
[Test]
public void OneSimpleTest()
{
var eightBall = new EightBall();
Task<bool> answer = eightBall.ShouldIChangeJob();
answer.Wait();
Assert.That(answer.Result, Is.True);
}
You can’t perform that action at this time.