This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: a quiz | |
Background: | |
Given the quiz is configured with the questions: | |
""" | |
[ | |
{"key": "foo", "question": "1+1", "answer": "2", "reference-url": "questions/foo.html"}, | |
{"key": "bar", "question": "1x3", "answer": "3", "reference-url": "questions/bar.html"} | |
] | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Only validation that should happen per load. | |
def person_loading_validator(person): | |
if len(person.name) < 1: | |
raise Exception("One or more characters required.") | |
# Only validation that should happen on every save. | |
def person_saving_validator(person): | |
if len(person.name) < 1: | |
raise Exception("One or more characters required.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new House( | |
new Kitchen( | |
new Fridge( | |
new Beer(), | |
new Pizza() | |
) | |
), | |
new Lounge( | |
new Sofa() | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new House( | |
KitchenModule().Resolve(), | |
new Lounge( | |
new Sofa() | |
), | |
new Hallway(), | |
new Bedroom() | |
new Garden() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Customer | |
{ | |
public void PlaceOrder(Order order) | |
{ | |
if (order.Cancelled || order.IsReplacement) | |
{ | |
// Do stuff... | |
} | |
// Snip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Customer | |
{ | |
private class OrderStatusFlag | |
{ | |
// Snip | |
} | |
public void PlaceOrder(Order order) | |
{ | |
var validator = new Validator(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Execute(string input) | |
{ | |
// Snip... | |
messageRepository.Save(new Message(input)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Execute(string input) | |
{ | |
// Snip... | |
messageRepository.Save(messageFactory.Create(input)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class ConsumerTests | |
{ | |
[Test] | |
public void Test() | |
{ | |
// Arrange | |
var messageFactory = new Mock<IMessageFactory>(); | |
var message = new Message("Hello, World"); | |
messageFactory.Setup(x => x.Create()).Returns(message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class ConsumerWithoutFactoryTests | |
{ | |
[Test] | |
public void Test() | |
{ | |
// Arrange | |
var messageRepository = new Mock<IMessageRepository>(); | |
var subject = new ConsumerWithoutFactory(messageRepository.Object); |
OlderNewer