Skip to content

Instantly share code, notes, and snippets.

@DavidArno
DavidArno / Multiple assert per test
Created July 7, 2011 16:27
Comparison of multiple assert per test versus single assert per test
[Test]
public function initialiseSetsUpModelStateAndMap():void
{
var model:Model = new Model();
var state:State = new State();
var map:Dictionary = new Dictionary();
initialise(model, state, map);
assertThat(_model, strictlyEqualTo(model));
@DavidArno
DavidArno / gist:1186095
Created September 1, 2011 12:47
Is this a code smell? Writing code to support testing
The following two methods use the currentDateTime() method to get the current time,
rather than calling new Date() directly. the only reason I did this was so that I
could override currentDateTime() in my test case class in order to pass in an
existing Date object to ensure that the time would not have changed between the
method being called and the assert made.
Is this bad practice? I can't decide.
/**
* Callback method used by _macroSubstitutions to provide the current date in DD_MMM_YYYY format
import flash.display.MovieClip
import flash.display.Sprite
import haxe.Timer
import flash.Lib
class MathSinbyexample
@RED: Int = 0xFF0000
_stage:MovieClip
_view_mc:Sprite
_wide:Int
@DavidArno
DavidArno / gist:1709906
Created January 31, 2012 11:00
AS3 enum example
Enum base class:
package language.extensions.enums
{
public class EnumBase
{
function EnumBase(token:*)
{
if (token !== runtimeInstantiationPreventionKey)
{
@DavidArno
DavidArno / Resharper bad code advice
Created July 11, 2012 11:12
Resharper bad code advice
Take the following method:
private void UpdateCurrentBall()
{
_currentBall++;
if (_currentBall == 3)
{
_currentBall = 0;
_currentFrame++;
}
@DavidArno
DavidArno / Type<T> example
Created July 20, 2012 11:44
Type<T> example
I have a class that is similar to:
public class SystemConfiguration<T1, T2, T3, T4, T5>
where T1 : ILogger, new()
where T2 : IReporter, new()
where T3 : IQueue, new()
where T4 : IConfiguration, new()
where T5 : ILauncher, new()
{
public SystemConfiguration()
In Lapsang static composition can be used to add features to types in a way that can be validated by the compiler.
The syntax for a new function component takes the form:
package some.component.package.name
component returnType functionName(type someName) default implFunctionName
component returnType implFunctionName(type someName)
code goes here
DoSomethingCodeA();
try
{
var exceptionsToBeIgnored = false;
foreach (var x in SomeExpression)
{
exceptionsToBeIgnored = true;
DoSomethingCodeB();
exceptionsToBeIgnored = false;
}
@DavidArno
DavidArno / SimplifiedCat
Created June 1, 2015 12:45
Simplified cat
public class Cat
{
public string Name { get; set; }
public string Color { get; set; }
public Cat()
{
Cat("Unamed", "gray");
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace GithubWikiDoc
{