Skip to content

Instantly share code, notes, and snippets.

View MattHoneycutt's full-sized avatar

Matt Honeycutt MattHoneycutt

View GitHub Profile
@MattHoneycutt
MattHoneycutt / GridTag.cs
Created November 14, 2015 02:59
Updated MvcGridDirective and GridTag that allows for cell templates.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web.UI;
using HeroicCRM.Web.Utilities;
using HtmlTags;
namespace HeroicCRM.Web.Helpers
{
@MattHoneycutt
MattHoneycutt / gist:97342b8f79e1cc378d14
Created October 24, 2014 15:50
Create a new git repo with a standard .gitignore
$StandardGitIgnoreFile = Resolve-Path ".\std.gitignore"
function Git-InitStandard() {
git init .
Copy-Item $StandardGitIgnoreFile ".\.gitignore"
Write-Host "Added standard gitignore file."
}
<#
This assumes you have a file next to your Powershell profile (where this function is defined) named std.gitignore. Here's what's in mine:
using SpecsFor;
public class OrderProcessorSpecs : SpecsFor<OrderProcessor>
{
ProcessingResult _result;
protected override void Given()
{
GetMockFor<IInventory>()
.Setup(i => i.IsQuantityAvailable("TestPart", 10))
.Returns(true)
using SpecsFor;
public class OrderProcessorSpecs : SpecsFor<OrderProcessor>
{
[Test]
public void Order_submitted_successfully_Tests()
{
GetMockFor<IInventory>()
.Setup(i => i.IsQuantityAvailable("TestPart", 10))
.Returns(true)
.Verifiable();
using System.Web.Mvc;
namespace HeroicSupport.Web.Filters
{
public class StandardModelStateValidationAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!filterContext.Controller.ViewData.ModelState.IsValid)
{
@MattHoneycutt
MattHoneycutt / ModularConventionViewEngine.cs
Created May 2, 2013 02:09
A Razor view engine that supports several methods of organizing views and controllers within the same folder.
public class ModularConventionViewEngine : RazorViewEngine
{
//This needs to be initialized to the root namespace of your MVC project.
//Usually, the namespace of your Global.asax's codebehind will do the trick.
private static readonly string RootNamespace = typeof(MvcApplication).Namespace;
private static IEnumerable<string> GetPath(ControllerContext controllerContext, string viewName)
{
var paths = new List<string>();
@MattHoneycutt
MattHoneycutt / DecorateThis.cs
Created September 9, 2012 21:12
StructureMap Decorator
public static class StructureMapDecoratorHelperExtension
{
public static DecoratorHelper<TTarget> Decorate<TTarget>(this SmartInstance<TTarget> instance)
{
return new DecoratorHelper<TTarget>(instance);
}
}
public class DecoratorHelper<TTarget>
@MattHoneycutt
MattHoneycutt / UserRegistrationSpecs.cs
Created March 18, 2012 05:02
SpecsFor.Mvc Examples
public class UserRegistrationSpecs
{
public class when_a_new_user_registers : SpecsFor<MvcWebApp>
{
protected override void Given()
{
SUT.NavigateTo<AccountController>(c => c.Register());
}
protected override void When()
@MattHoneycutt
MattHoneycutt / gist:1529690
Created December 28, 2011 20:54 — forked from jalchr/gist:1528815
SpecFor Sample
[Given(typeof(the_entity_is_available))]
public class When_entity_is_on_hold : SpecsFor<Entity>
{
public When_entity_is_on_hold(Type[] contexts) : base(contexts) { }
protected override void InitializeClassUnderTest()
{
SUT = new Entity("test");
}
public class when_creating_the_SUT_manually : SpecsFor<ReallyComplexAndHardToCreateType>
{
protected override void InitializeClassUnderTest()
{
SUT = ReallyComplexAndHardToCreateType.CreateMyType("some", "params", 536);
}
...
}