Skip to content

Instantly share code, notes, and snippets.

View adamralph's full-sized avatar
🤗
Living the dream

Adam Ralph adamralph

🤗
Living the dream
View GitHub Profile
@adamralph
adamralph / gist:3051724
Created July 5, 2012 06:19
RE: 3047138
public class Different
{
private ISomething something;
public Different(ISomethingProvider somethingProvider)
{
this.something = somethingProvider.Provide();
}
}
@adamralph
adamralph / gist:3184291
Created July 26, 2012 20:25
xBehave.net collection contents example
[Scenario]
public static void GettingACollection
{
var provider = default(CollectionProvider);
var collection = default(Collection);
"Given a collection provider"
.Given(() => provider = new CollectionProvider());
"When getting a collection"
@adamralph
adamralph / gist:3886106
Created October 13, 2012 20:49
xBehave.net re-write for bwatts
public class RuntimeFeature
{
[Scenario]
public void ApplyDependentCalculation()
{
int _left1;
int _right1;
int _left2;
Variable _outputVariable1;
Variable _outputVariable2;
@adamralph
adamralph / gist:3904338
Created October 17, 2012 08:16
xbehave background out param idea
[Background]
public static void Background(out Stack<int> stack)
{
"Given a stack"
.Given(() => stack = new Stack<int>());
}
[Scenario]
[Example(123)]
[Example(234)]
@adamralph
adamralph / NoBaseClass.cs
Created October 20, 2012 13:02 — forked from bwatts/NoBaseClass.cs
Behaviors with LINQ syntax using a scenario monad
public class IntervalFeature
{
[Scenario]
public void ComparisonUsingLinq()
{
var result =
from left in "Given an interval".Of(Interval.WholeStep)
from right in "And a smaller interval".Of(Interval.HalfStep)
select "When comparing the intervals".Do(left.CompareTo(right));
@adamralph
adamralph / github-jekyll-email
Created January 9, 2013 06:47
Email to GitHub support regarding Jekyll excerpts problem
Hi,
In my github pages site I have some code which generates excerpts from posts https://github.com/adamralph/adamralph.github.com/blob/master/index.html#L13
This worked on 6th Jan, which was the last time I pushed a change before today.
However, after pushing an unrelated change today, the code has stopped working. Instead of an excerpt, the entire post is shown - see http://www.adamralph.com/
Another user has also reported the same problem with his site and has temporarily removed his excerpts code, the diff is at https://github.com/alfhenrik/henri.kandersson.com/commit/b60804d36e203f14af312e08f4c2e5b566cc9fc8#L0L15
@adamralph
adamralph / gist:4746267
Last active December 12, 2015 08:48
I <3 xBehave.net! for more info see https://github.com/xbehave/xbehave.net
[Scenario]
[Example(typeof(int), 0)]
[Example(typeof(object), null)]
public static void GeneratedDefaultValue<TValue>
(Type type, TValue expectedValue, Argument argument)
{
"Given the type {0}"
.Given(() => { });
"When constructing an argument using the type"
@adamralph
adamralph / xBehave.net with ExpandoObject
Last active December 12, 2015 10:39
I did a spike once for xBehave.net which would allow this in .NET 4.0+. The `scenario` object which is passed as an argument to each step expression is an `ExpandoObject` typed as `dynamic`. I'd love to come up with a solution which doesn't have the issue noted in the code.
[Scenario]
public void PushingAnElementOntoAStack() // No parameters :-D
{
"Given an element"
.Given(scenario => scenario.Element = 11);
"And a stack"
.And(scenario => scenario.Stack = new Stack<int>());
"When pushing the element onto the stack"
@adamralph
adamralph / gist:5072250
Created March 2, 2013 18:03
FakeItEasy ILMerge integration test failure
Errors and Failures:
1) Test Error : FakeItEasy.IntegrationTests.ConfigurationTests.Should_be_able_to_configure_indexed_properties
FakeItEasy.Core.FakeCreationException :
Failed to create fake of type "FakeItEasy.IntegrationTests.ConfigurationTests+IIndexed".
Below is a list of reasons for failure per attempted constructor:
No constructor arguments failed:
No default constructor was found on the type FakeItEasy.IntegrationTests.ConfigurationTests+IIndexed.
@adamralph
adamralph / gist:5076908
Last active December 14, 2015 11:09
FakeItEasy Should_match_lambda_arguments
[Test]
public void Should_match_lambda_arguments()
{
// Arrange
var fake = A.Fake<ITypeWithMethodWithDelegateParameter>();
var action = (Action)(() => { });
var other = (Action)(() => { });
// Act
fake.Foo(action);