Skip to content

Instantly share code, notes, and snippets.

View chrisoldwood's full-sized avatar

Chris Oldwood chrisoldwood

View GitHub Profile
@chrisoldwood
chrisoldwood / PowerShellExitTest.ps1
Last active August 16, 2023 13:49
A set of tests to show if your version of PowerShell returns the correct exit code under various error conditions.
exit 1
@chrisoldwood
chrisoldwood / CheckPackageCache.ps1
Last active November 24, 2018 23:29
Checks the solution's packages folder looking for multiple versions of the same package.
<#
.synopsis
Looks for multiple versions of the same NuGet package in the NuGet
packages folder for a .Net based soluton.
.description
If you check your NuGet dependencies into your source control repository
it's easy for old versions to be left hanging around. This script, a
companion to CheckPackageVersions, highlights where you might have stale
packages left behind.
@chrisoldwood
chrisoldwood / CheckPackageVersions.ps1
Last active November 24, 2018 23:31
Checks all packages.config files looking for version mismatches between different projects.
<#
.synopsis
Scans the packages.config files in a .Net solution looking for multiple
versions of the same package.
.description
Ideally your .Net based solutions should always be using a consistent
set of NuGet packages to avoid subtle bugs. This script, a companion to
CheckPackageCache, analyses all the NuGet packages used by your solution
and tells you if multiple package versions are being referenced.
@chrisoldwood
chrisoldwood / SimpleDependencyResolver.cs
Created January 14, 2016 21:28
A minimalist IoC container for use with ASP.Net/OWIN.
using System;
using System.Collections.Generic;
using System.Web.Http.Dependencies;
namespace WebApi
{
using TypeFactories = Dictionary<Type, Func<object>>;
public sealed class SimpleDependencyResolver : IDependencyResolver
{
@chrisoldwood
chrisoldwood / CreateAssemblyVersionInfo.txt
Last active May 18, 2016 10:42
Visual C# pre-build step to generate a common AssemblyVersionInfo.cs from a version number defined by a couple of environment variables.
<PreBuildEvent>
if not defined PRODUCT_VERSION set PRODUCT_VERSION=0.0.0
if not defined BUILD_NUMBER set BUILD_NUMBER=1
echo using System.Reflection;&gt;"$(SolutionDir)Source\AssemblyVersionInfo.cs"
echo [assembly: AssemblyVersion("%25PRODUCT_VERSION%25.%25BUILD_NUMBER%25")]&gt;&gt;"$(SolutionDir)Source\AssemblyVersionInfo.cs"
</PreBuildEvent>
@chrisoldwood
chrisoldwood / Test-Driven-SQL-Procedure.sql
Last active January 14, 2016 22:13
The final versions of the example SQL code written during my live-coding Test-Driven SQL talk
if (object_id('pub.ReportBugsPerDeveloper') is not null)
drop procedure pub.ReportBugsPerDeveloper;
go
create procedure pub.ReportBugsPerDeveloper
as
select
su.FirstName + ' ' + su.LastName as FullName,
count(b.BugId) as BugCount
from
@chrisoldwood
chrisoldwood / SpecFlow.Hooks.cs
Last active December 5, 2022 10:39
Custom SpecFlow listener and "logging" class to reduce noise when running SpecFlow tests from the command line.
using TechTalk.SpecFlow;
namespace MyCompany.SpecFlowTests
{
[Binding]
public static class Hooks
{
[BeforeFeature]
public static void BeforeFeature()
{