Skip to content

Instantly share code, notes, and snippets.

View simoneb's full-sized avatar

Simone Busoli simoneb

View GitHub Profile
@simoneb
simoneb / nunit-simple-async-test.cs
Last active December 11, 2015 08:48
A simple async test
[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-async-task-test.cs
Created January 20, 2013 00:05
A simple async test returning Task
[Test]
public async Task OneSimpleTest()
{
var eightBall = new EightBall();
var answer = await eightBall.ShouldIChangeJob();
Assert.That(answer, Is.True);
}
@simoneb
simoneb / nunit-async-testcase.cs
Last active December 11, 2015 09:08
An async test case returning Task<int>
[TestCase(1, 2, Result = 3)]
public async Task<int> TestAddAsync(int a, int b)
{
return await SumAsync(a, b);
}
public async Task<int> SumAsync(int a, int b)
{
return await Task.FromResult(a) + await Task.FromResult(b);
}
@simoneb
simoneb / async-lambda-support.cs
Created January 20, 2013 11:50
Async lambda support in NUnit framework
[Test]
public async Task AsyncLambaSupport()
{
// throwing asynchronously
Assert.That(async () => await ThrowAsync(), Throws.TypeOf<InvalidOperationException>());
// returning values asynchronously
Assert.That(async () => await ReturnOneAsync(), Is.EqualTo(1));
// "After" works with async methods too
@simoneb
simoneb / gist:4997391
Created February 20, 2013 17:39
Path.GetDirectoryName behavior
Console.WriteLine(Path.GetDirectoryName(@"c:\windows\temp")); // c:\windows
Console.WriteLine(Path.GetDirectoryName(@"c:\windows\temp\")); // c:\windows\temp !!!
@simoneb
simoneb / readme
Last active December 14, 2015 03:29
TypeScript - Sublime Text2 build system configuration
1 - Copy the file typescript.sublime-build in %appdata%\Sublime Text 2\Packages\User
2 - Edit a .ts file
- CTRL+B will compile to .js and save to the same path as the .ts file
- CTRL+SHIFT+B will compile to .js and create+run an HTML page which embeds the script
@simoneb
simoneb / monadic-labeling.cs
Last active December 15, 2015 22:19
Monadically labeling a binary tree
<Query Kind="Program" />
void Main()
{
var tree = branch(
leaf("a"),
branch(
branch(
leaf("b"),
leaf("c")),
<project name="Hello World" default="build" basedir=".">
<description>The Hello World of build files</description>
<property name="debug" value="true" overwrite="false" />
<target name="build" description="greets you">
<echo message="hey there" />
</target>
</project>
@simoneb
simoneb / repro.js
Last active February 15, 2016 22:42
repro
let stream;
let events = ['message', 'tweet', 'delete', 'limit', 'scrub_geo', 'disconnect',
'connect', 'connected', 'reconnect', 'warning', 'status_withheld',
'user_withheld', 'friends', 'direct_message', 'user_event'];
function start(path, params) {
if (stream) stream.stop();
let T = new Twit({
@simoneb
simoneb / linqpad-nunitlite.cs
Created October 29, 2012 00:42
NUnitLite in LINQPad
void Main()
{
new NUnitLite.Runner.TextUI().Execute(new[]{"-noheader"});
}
// Define other methods and classes here
[Test]
public void SomeTest()
{
Assert.Pass();