Skip to content

Instantly share code, notes, and snippets.

@timwingfield
timwingfield / MoqSetupStub.cs
Created July 27, 2011 06:02
Setting up a Stub with Moq
[TestFixture]
public class When_loading_the_vehicle_list_and_there_two_available_vehicles : Specification
{
protected Mock<IVehicleRepository> _vehicleRepository;
protected List<Vehicle> _vehicles;
protected VehicleViewModel _vehicleViewModel;
protected override void before_each()
{
require 'rubygems'
require 'sinatra'
require 'sinatra/base'
require 'my_trip/app'
require 'rack/test'
require 'rspec'
require 'mongoid'
set :environment, :test
set :run, false
describe PersonTest, "when testing an isolation" do
before :each do
@isolation = Isolation.for IPerson
@pt = PersonTest.new(@isolation)
@pt.set_person_age_to_twenty
end
it "should have the age set to 20" do
@pt.person.age.should be(20)
end
@timwingfield
timwingfield / test setup for Andrew
Created June 10, 2010 12:37
poor man's DI, repo, service, etc, etc
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CODODN
{
public interface IRepository
{
string SomethingYouNeed { get; set; }
@timwingfield
timwingfield / Albacore MSBuild Task
Created May 5, 2010 17:25
Albacore MSBuild Task
desc "Build TicTacToe using the MSBuildTask"
msbuild :msbuild do |msb|
msb.properties :configuration => :Release
msb.targets :Clean, :Build
#msb.verbosity :verbosity => 'q'
msb.solution = "../TicTacToe.sln"
end
@timwingfield
timwingfield / specification.cs
Created March 30, 2010 17:08
Specification class I use to help with TDD
using System;
using System.Diagnostics;
using System.Reflection;
using NUnit.Framework;
using Rhino.Mocks;
using Rhino.Mocks.Impl;
using Rhino.Mocks.Interfaces;
using StructureMap.AutoMocking;
namespace ExpressSpringBreak.Web.Tests
public class RepositoryConventionScanner : IRegistrationConvention
{
public void Process(Type type, Registry registry)
{
Type repoForType = GetGenericParamFor(type.BaseType, typeof(Repository<>));
if (repoForType != null)
{
var genType = typeof(IRepository<>).MakeGenericType(repoForType);
registry.For(genType).Add(typeof (Repository<>));
@timwingfield
timwingfield / photoRepo
Created March 5, 2010 13:28
Photo Repo
public interface IPhotoRepository : IRepository<Photo>
{
IList<Photo> GetPhotosByGallery(Gallery gallery);
}
public class PhotoRepository : Repository<Photo>, IPhotoRepository
{
public PhotoRepository(ISession session) : base(session)
@timwingfield
timwingfield / sm setup
Created March 2, 2010 21:02
FNH + SM configuration
using System;
using System.Configuration;
using FluentNHibernate;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using StructureMap;
public static class Bootstrapper
{
@timwingfield
timwingfield / .net .gitignore
Created February 10, 2010 18:56
.gitignore file for .net
[Oo]bj
[Bb]in
*.user
*.suo
*.[Cc]ache
*.bak
*.ncb
*.log
*.DS_Store
[Tt]humbs.db