Skip to content

Instantly share code, notes, and snippets.

View stevenharman's full-sized avatar

Steven Harman stevenharman

View GitHub Profile
using System.Reflection;
using FluentNHibernate.AutoMap;
using FluentNHibernate.Framework;
using MyApplication.Core.Domain;
namespace MyApplication.Core.Persistence
{
public class MyCustomPersistenceModel : AutoPersistenceModel
{
public MyCustomPersistenceModel()
using System.Reflection;
using FluentNHibernate.AutoMap;
using FluentNHibernate.Framework;
using MyApplication.Core.Domain;
namespace MyApplication.Core.Persistence
{
public class MyCustomPersistenceModel : AutoPersistenceModel
{
public MyCustomPersistenceModel()
using System;
using System.Reflection;
using FluentNHibernate.AutoMap;
using FluentNHibernate.Framework;
using MyApplication.Core.Domain;
namespace MyApplication.Core.Persistence
{
public class MyApplicationPersistenceModel : AutoPersistenceModel
{
namespace MyApplication.UnitTests.Core.Persistence
{
[Category("MyApplicationPersistenceModel")]
public class when_using_the_plan_my_night_persistence_model
: Specification, with_auto_persistence_model
{
private MyApplicationPersistenceModel _model;
public override void establish_context()
{
public class FindGoodStuffQuery : INamedQuery<Idea>
{
public IQueryable<Stuff> Apply(IQueryable<Stuff> queryable)
{
return queryable
.OrderByDescending(s => s.Widgets.Count())
.ThenByDescending(s => s.CreatedAt);
}
}
public class FindGoodStuffQuery : INamedQuery<Idea>
{
public IQueryable<Stuff> Apply(IQueryable<Stuff> queryable)
{
return queryable
.OrderByDescending(s => s.Widgets.Count())
.ThenByDescending(s => s.CreatedAt);
}
}
public class when_requesting_a_custom_logo_and_none_is_configured : concerns<CustomizationController>
{
private readonly Type NotFoundException = typeof (HttpException);
private CustomizationController _controller;
protected override void Context()
{
Dependency<IConfigureTheApplication>().Stub(i => i.Logo).Return(null);
_controller = BuildUp();
}
// started here
public class Entry : Entity
{
private DateTime _createdAt;
public bool IsWithinEditWindow()
{
return _createdAt.IsAfter(20.Minutes().Ago());
}
}
/// <summary>
/// Bypasses IIS7 custom Errors.
/// </summary>
public class TrySkipIisCustomErrors : FilterAttribute, IActionFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
}
// extremely lame example, but I like the functional aspect of it.
// also, combining the bool/func pairs into objects (strategies) might
// be a nice way to cordon off the coupling. Oh, and the naming could
// much improved, which would help greatly with readability.
var use_public_forums =
new Dictionary<bool, Func<IEnumerable<Forum>, IEnumerable<Forum>>>
{
{true, forums => forums.Where(forum => !forum.IsPrivate)},
{false, forums => forums}