Skip to content

Instantly share code, notes, and snippets.

@bitsprint
bitsprint / HtmlHelperExtensions.cs
Created June 27, 2013 14:10
HtmlHelper Extensions
namespace Web.Extensions.Control
{
public static partial class HtmlHelperExtensions
{
// Usage: @Html.ListBoxWithAttributesFor(m => m.Foo, Model.Foos, false)
// See SelectListItemWithAttributes
public static MvcHtmlString ListBoxWithAttributesFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItemWithAttributes> selectList, bool multiple = true)
{
if (expression == null)
{
@bitsprint
bitsprint / MoqVerifier.cs
Created June 20, 2013 08:25
Test With Mocks base class (inherit from test)
namespace Core.Tests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Moq;
public static class MoqVerifier
@bitsprint
bitsprint / DependencyInjection.cs
Created June 14, 2013 10:33
Windsor Dependency Injection Setup
using System.Web;
using Web.AppStart;
[assembly: WebActivator.PreApplicationStartMethod(typeof(DependencyInjection), "BootstrapContainer")]
namespace Web.AppStart
{
using System;
using System.IO;
@bitsprint
bitsprint / global.asax.cs
Created June 14, 2013 09:21
ASP.NET MVC Application Global
namespace Web
{
using System;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using NLog;
using Web.AppStart;
using WebActivator;
[assembly: PostApplicationStartMethod(typeof(Bundles), "Start")]
namespace Web.AppStart
{
using System.Collections.Generic;
using System.Web;
DBCC CHECKIDENT ([Table], RESEED, X)
@bitsprint
bitsprint / FooDataBuilder.cs
Created June 11, 2013 15:04
Example Data Builder
namespace Tests.Domain.Builders
{
using System;
using System.Collections.ObjectModel;
using global::Core.Tests.Builders;
using Domain;
public class FooBuilder : TestDataBuilder<FooBuilder, Foo>
@bitsprint
bitsprint / AreaTests.cs
Created June 11, 2013 14:57
Area Route Test
[Test]
public void TestRoute_RoutesToCorrectRoute()
{
var routes = new RouteCollection();
var areaRegistration = new FooAreaRegistration();
Assert.AreEqual("Foo", areaRegistration.AreaName);
var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routes);
areaRegistration.RegisterArea(areaRegistrationContext);
@bitsprint
bitsprint / AreaRegistrationTests.DefaultRoute.cs
Created June 11, 2013 14:53
Area Registration Default Route Tests
[Test]
public void RegisterArea_RoutesToArea()
{
var routes = new RouteCollection();
var areaRegistration = new FooAreaRegistration();
Assert.AreEqual("Foo", areaRegistration.AreaName);
var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routes);
areaRegistration.RegisterArea(areaRegistrationContext);
@bitsprint
bitsprint / SecurityModule.cs
Created June 7, 2013 09:00
Security Module
namespace Core.Security
{
using System.Security.Cryptography;
using System.Text;
public class SecurityModule
{
public static string GetMd5Hash(string input)
{
var md5 = MD5.Create();