Skip to content

Instantly share code, notes, and snippets.

View johnnonolan's full-sized avatar

John Nolan johnnonolan

View GitHub Profile
@johnnonolan
johnnonolan / ap2.cs
Created July 24, 2012 10:45
autoprops
var p = new Patient{
PatientNo ="123",
FirstName = "John",
LastName = "Nolan,
FatherName = "Dad",
Children = new List { new Kid { FullName = "Johnetta" },
new Kid { FullName = "Johnella" } }
};
@johnnonolan
johnnonolan / ap1.cs
Created July 24, 2012 10:41
autoprops
public class Patient
{
public virtual string PatientNo { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual string TCId { get; set; }
public virtual string FatherName { get; set; }
public virtual string MotherName { get; set; }
public virtual string Sex { get; set; }
public virtual IList Children { get; set;}
@johnnonolan
johnnonolan / rounding.cs
Created May 3, 2012 10:03
I hate the rounding in .NET
namespace Rounding
{
[TestFixture]
public class Class1
{
//BRAIN HURTS
[Test]
public void Default()
{
Assert.That(Decimal.Round(1.5m),Is.EqualTo(2));
@johnnonolan
johnnonolan / gist:2295033
Created April 3, 2012 19:42
regiontastic!
class StubPaymentAccountRepository : IPaymentAccountRepository
{
public List<PaymentAccount> Payments { get; set; }
public StubPaymentAccountRepository()
{
Payments = new List<PaymentAccount>();
}
public void Add(IEnumerable<PaymentAccount> entities)
{
@johnnonolan
johnnonolan / nonullrefexceptions.cs
Created March 16, 2012 15:28
look ma no null reference exceptions!
public class When_blah
{
static string s;
Establish that = () => s = null;
Because of = () => s= s.MyExt();
It should_be_null = () => s.ShouldBeNull();
}
public static class MyExts
public class MyController
{
//in state testing ALL we can test is the state of the result.
public ActionResult myAction()
{
//some controller stuff
return result;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace TestUoWPoC
{
class Program
{
@johnnonolan
johnnonolan / a.cs
Created February 13, 2012 15:53
Iterating through a enum
foreach (var style in Enum.GetValues(typeof(TradingStyle)).Cast<TradingStyle>())
@johnnonolan
johnnonolan / ooguru.cs
Created February 8, 2012 09:04
Signs that the author is not an OO Guru #54
Welcome objWelcome = new Welcome();
@johnnonolan
johnnonolan / nh.cs
Created January 4, 2012 16:22
nh headache
// I'm trying to dynamically build up criteria
ICriteria criteria = session.CreateCriteria<Client>().Add(BuildCriteria(clientParams));
static ICriterion BuildCriteria(IEnumerable<MatchableClientParams> clientParams)
{
var result = Restrictions.Disjunction();
foreach (var parameters in clientParams)
{