Skip to content

Instantly share code, notes, and snippets.

@MattHoneycutt
Created June 16, 2014 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattHoneycutt/173cf7a4e403266733fa to your computer and use it in GitHub Desktop.
Save MattHoneycutt/173cf7a4e403266733fa to your computer and use it in GitHub Desktop.
using SpecsFor;
public class OrderProcessorSpecs : SpecsFor<OrderProcessor>
{
ProcessingResult _result;
protected override void Given()
{
GetMockFor<IInventory>()
.Setup(i => i.IsQuantityAvailable("TestPart", 10))
.Returns(true)
.Verifiable();
}
protected override void When()
{
_result = SUT.Process(new Order {PartNumber = "TestPart", Quantity = 10});
}
[Test]
public void then_the_order_is_accepted()
{
_result.WasAccepted.ShouldBeTrue();
}
[Test]
public void then_it_checks_the_quantity()
{
GetMockFor<IInventory>().Verify();
}
[Test]
public void then_it_raises_a_new_event()
{
GetMockFor<IPublisher>()
.Verify(p => p.Publish(It.Is<OrderSubmitted>(o => o.OrderNumber == result.OrderNumber)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment