Skip to content

Instantly share code, notes, and snippets.

View MattHoneycutt's full-sized avatar

Matt Honeycutt MattHoneycutt

View GitHub Profile
public interface IRepository<TEntity>
{
void Save(TEntity entity);
IQueryable<TEntity> Query();
}
public class when_creating_an_issue : given.the_default_state
{
...snip...
}
public static class given
{
public abstract class the_default_state : SpecsFor<AddIssueController>
{
protected User TestUser;
public abstract class SpecsForWithData<T> : SpecsFor<T> where T : class
{
protected User TestUser;
protected User CreatorUser;
protected Issue TestIssue;
protected Project TestProject;
protected override void Given()
{
CreateUsers();
public static class given
{
public abstract class the_default_state : SpecsForWithData<AddIssueController>
{
}
}
public class InvoiceProcessorSpecs
{
public class when_processing_an_invoice_with_helpers : SpecsFor<InvoiceProcessor>
{
...
[Test]
public void then_it_publishes_an_event()
{
GetMockFor<IPublisher>()
@MattHoneycutt
MattHoneycutt / DemoWebAppConfig.cs
Created November 27, 2011 18:43
SpecsFor.Mvc examples
[SetUpFixture]
public class DemoWebAppConfig : SpecsForMvcConfig
{
public DemoWebAppConfig()
{
UseIISExpressWith(Project("SpecsFor.Mvc.Demo"));
BuildRoutesUsing(r => MvcApplication.RegisterRoutes(r));
UseBrowser(BrowserDriver.InternetExplorer);
//TODO: Open questions to be answered:
protected override void Given()
{
//Access Moq objects easily
GetMockFor<IInventory>()
.Setup(i => i.IsQuantityAvailable("TestPart", 10))
.Returns(true)
.Verifiable();
}
protected override void When()
public class when_creating_the_SUT_manually : SpecsFor<ReallyComplexAndHardToCreateType>
{
protected override void InitializeClassUnderTest()
{
SUT = ReallyComplexAndHardToCreateType.CreateMyType("some", "params", 536);
}
...
}
@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");
}
@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()