Skip to content

Instantly share code, notes, and snippets.

@tkellogg
Created December 28, 2011 17:44
Show Gist options
  • Save tkellogg/1528845 to your computer and use it in GitHub Desktop.
Save tkellogg/1528845 to your computer and use it in GitHub Desktop.
BDD in C#
[TestFixture]
class when_adding_numbers
{
Maths maths;
void Given_an_object_in_bigint_mode()
{
maths = new Maths();
maths.BigInt = true;
}
[Test]
public void it_doesnt_overflow_the_size_of_an_int()
{
Given_an_object_in_bigint_mode();
Assert.That(maths.Add(int.MAX, 1), Is.GreaterThan(int.Max));
}
}
var spec = new Spec(describe: typeof(Maths));
spec.It["doesn't overflow the size of an int"] = maths.Add(int.MAX, 1).Should() > int.MAX
maths.Add(int.MAX, 1).Should() > int.MAX;
describe "Maths#add" do
before :each do
@math = Maths.new
end
context "when in bigint mode" do
before :each do
@math.bigint = true
end
it "doesn't overflow the size of an int" do
@math.add(int.MAX, 1).should > int.MAX
end
end
end
maths.Add(int.MAX, 1).Should().BeGreaterThan(int.MAX);
describe "Maths#add" do
before :each do
@math = Maths.new
end
it "should add two numbers" do
@math.add(5, 6).should == 11
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment