Skip to content

Instantly share code, notes, and snippets.


Jeroen Heijmans jeroenheijmans

View GitHub Profile
jeroenheijmans / StringExtensions-Truncate.cs
Last active Nov 28, 2016
String Truncate method with test coverage
View StringExtensions-Truncate.cs
// CC-BY-SA 3.0, implementation by @LBushkin from
public static class StringExtensions
public static string Truncate(this string value, int maxLength)
if (maxLength < 0) throw new ArgumentOutOfRangeException("maxLength");
if (string.IsNullOrEmpty(value)) return value;
return value.Length <= maxLength ? value : value.Substring(0, maxLength);
View RegexForBadRethrows.txt
// This regex is a basic check to find all Catch{} blocks
// where a suspect throw statement is found (e.g. a state-
// ment that mucks up the call stack by doing `throw ex;`
// instead of `throw;`.
// It'll probably give false positives and have misses too.
jeroenheijmans / DtoTests.cs
Created Mar 20, 2016
All Collection properties should be instantiated for types with empty constructors
View DtoTests.cs
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace MyProject.Dto.Tests
jeroenheijmans / NHibernateUnitTests.cs
Last active Mar 20, 2016
Minmal Repro for NHibernate issues (SSCCE / MCVE)
View NHibernateUnitTests.cs
/* Gist for minimal repro for NHibernate issues
* 1. Create new (e.g. .NET 4.5.1) class library;
* 2. Add NHibernate (e.g. 4.0.3) via NuGet;
* 3. Add FluentNHibernate (e.g. 2.0.1) via NuGet;
* 4. Add NUnit (e.g. 2.6.4) via NuGet;
* 5. Create database "NhTestDb" on Sql Server "localhost" (or adjust for your specific situation);
* 6. Compile;
* 7. Run tests (should be green).