Skip to content

Instantly share code, notes, and snippets.

public static class TestHelpers
{
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue)
{
ShouldEqualWithDiff(actualValue, expectedValue, DiffStyle.Full, Console.Out);
}
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue, DiffStyle diffStyle)
{
ShouldEqualWithDiff(actualValue, expectedValue, diffStyle, Console.Out);
@badmotorfinger
badmotorfinger / gist:5575139
Created May 14, 2013 10:55
Formats all SQL scripts in a directory using a free webservice provided by tsqltidy.com and PowerShell.
$uri = 'http://www.tsqltidy.com/SQLTidy.asmx'
$proxy = New-WebServiceProxy -Uri $uri -class FormatSQL -Namespace FormatSQL
#Warning - Will format file contents and overwrite the original file. Use with caution.
gci *.sql | % { $content = $proxy.ParseSQL((get-content $_.FullName)); Set-Content $_.FullName $content; }
@badmotorfinger
badmotorfinger / TryParseFunc.cs
Created July 18, 2012 03:38
Generic function to cast a string value to another value using .NET's built in TryParse methods.
// Usage
var intResult = Parse("1", 0, int.TryParse); // Returns 1
var dateResult = Parse("asdf", DateTime.Now, DateTime.TryParse); // Returns 18/07/2012 1:39:06 PM
delegate TParsedValue ParseFunc<T, U, TParsedValue>(T input, out U output);
static V Parse<T, V>(T valueToBeParsed, V defaultVal, ParseFunc<T, V, bool> dele) {
V result;
@badmotorfinger
badmotorfinger / psmo.ps1
Last active February 12, 2024 00:18
Generates scripts for most SQL Server database objects using PowerShell (SMO objects)
################################################################################################################################
#
# Script Name : SmoDb
# Version : 1.0
# Author : Vince Panuccio
# Purpose :
# This script generates one SQL script per database object including Stored Procedures,Tables,Views,
# User Defined Functions and User Defined Table Types. Useful for versionining a databsae in a CVS.
#
# Usage :
@badmotorfinger
badmotorfinger / JoinedStreamReader.cs
Created October 30, 2011 00:18
A collection of streams that can be read as one continuous stream
namespace Mvc.ResourceLoader.Util {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
public class JoinedStreamReader : Stream {