Skip to content

Instantly share code, notes, and snippets.

View johnnonolan's full-sized avatar

John Nolan johnnonolan

View GitHub Profile
namespace When
{
[Subject(typeof())]
public class Figuring_out_mSpec
{
It should_be_unspeced_here;
It should_fail_here_too = () =>
returnFalse().ShouldBeFalse(); // ShouldBeFalse is an extension method in mspec.
It should_pass_here = () =>
s.Contains("o").ShouldBeTrue(); // ShouldBeTrue is an extension method in mspec.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EnumTest
{
public enum MyEnum
{
[Subject(typeof(ContentPage))]
public class Creating_a_ContentPage
{
Establish context = () =>
{
mocker = new RhinoAutoMocker<ContentPageController>();
contentPageController = mocker.ClassUnderTest;
};
public ActionResult Index()
{
var meh =
_meh.GetMeh(contentpageId);
var blah = something.GetValueOrDefault() ?
something.Something : something.Something.Where(s => s.SomethingElse);
var aTruth = _wibble.IsThisTrue(whee);
var arghh =
public class AutoMockingContext<TUnderTest> where TUnderTest : class
{
protected static MoqAutoMocker<TUnderTest> autoMocker;
Establish automocking = () => autoMocker = new MoqAutoMocker<TUnderTest>();
protected static Mock<TInterface> Stub<TInterface>() where TInterface : class
/// some codez
if ( ctrl is CheckBox)
{
AddToDictionary(ctrl);
}
if ( ctrl is RadioBox)
{
@johnnonolan
johnnonolan / gist:647271
Created October 26, 2010 16:48
argh.cs
writer.Write(
string.Format("{0}:",
_meaningfulNameService.WellNamedMethod(
wellnamedType == WellNamedType.WellNameProperty &&
(goodname.wellnamedProperty == "Something" ||
goodname.wellnamedProperty == "Somethingelse")
? "Total"
: (goodname.wellnamedProperty != "Something" &&
goodname.wellnamedProperty != "SomethingElse")
? string.Format("Total for <br/>{0} to {1}",
@johnnonolan
johnnonolan / naughtyMe
Created December 14, 2010 22:33
I've been told off
Hi John,
Please try to use the [email protected] address responsibly, i.e. to send emails that actually concern an appreciable proportion of the postgrad population within the school. This isn't really the place to bitch about 3rd party websites like bcs.org (perhaps you can find a relevant newsgroup, message board or IRC channel in which to discuss their website).
Furthermore, if spam is causing a problem for you, I will be happy to suggest some basic steps you can take to filter it out of your inbox. Many computer science postgrads have a computer-oriented background, and therefore are familiar with solutions that prevent '75% spam' from cluttering their inboxes. If, rather, you object to the idea of there being spam emails sent to your address in the first place, you could take your concerns directly to Duty Office.
Hope this helps,
Richard
@johnnonolan
johnnonolan / gist:779683
Created January 14, 2011 14:41
x.feature
Feature:
(Constraint)
In order to track the author of documentation and comments
I need to provide a way to identify users
Scenario: An anonymous user requests an iDoc identity with valid details
Given I am not identified
When I go to the new account page
And I enter the required account details
And I press "Register"
namespace iDoc.specs.When
{
[Subject("AcccountManagement")]
public class CreatingAUserAccount : BaseContext<AccountController>
{
const string EmailAddress = @"[email protected]";
Establish context = () =>
{