diff --git a/BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj b/BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj index 3ee22ad..7f34dc5 100644 --- a/BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj +++ b/BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj @@ -38,6 +38,18 @@ ..\packages\LightBDD.NUnit.1.7.1.0\lib\net40\LightBDD.NUnit.dll True + + ..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.dll + True + + + ..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.Clr4.dll + True + + + ..\packages\Machine.Specifications.Should.0.9.0\lib\net45\Machine.Specifications.Should.dll + True + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll True @@ -56,6 +68,7 @@ Stack_feature.cs + diff --git a/BDD/ConductOfCode/ConductOfCode/MSpec/README.md b/BDD/ConductOfCode/ConductOfCode/MSpec/README.md new file mode 100644 index 0000000..d9654c9 --- /dev/null +++ b/BDD/ConductOfCode/ConductOfCode/MSpec/README.md @@ -0,0 +1,5 @@ +# Machine.Specifications (MSpec) + +* Dependencies: - +* NuGet: https://www.nuget.org/packages/Machine.Specifications/ +* Source: https://github.com/machine/machine.specifications diff --git a/BDD/ConductOfCode/ConductOfCode/MSpec/StackSpecs.cs b/BDD/ConductOfCode/ConductOfCode/MSpec/StackSpecs.cs new file mode 100644 index 0000000..706cb31 --- /dev/null +++ b/BDD/ConductOfCode/ConductOfCode/MSpec/StackSpecs.cs @@ -0,0 +1,49 @@ +using System; +using Machine.Specifications; + +namespace ConductOfCode.MSpec +{ + using System.Collections.Generic; + + public class StackSpecs + { + [Subject(typeof(Stack<>))] + public class When_empty + { + Establish context = () => + { + Subject = new Stack(); + }; + + It should_have_no_elements = () => Subject.ShouldBeEmpty(); + It should_throw_an_exception_when_calling_pop = () => Catch.Exception(() => Subject.Pop()).ShouldBeOfExactType(); + It should_throw_an_exception_when_calling_peek = () => Catch.Exception(() => Subject.Peek()).ShouldBeOfExactType(); + + static Stack Subject; + } + + [Subject(typeof(Stack<>))] + public class When_not_empty + { + Establish context = () => + { + Subject = new Stack(new[] { 1, 2, 3 }); + }; + + It should_return_the_top_element_when_calling_peek = () => Subject.Peek().ShouldEqual(3); + It should_not_remove_the_top_element_when_calling_peek = () => + { + Subject.Peek(); + Subject.ShouldContain(3); + }; + It should_return_the_top_element_when_calling_pop = () => Subject.Pop().ShouldEqual(3); + It should_remove_the_top_element_when_calling_pop = () => + { + Subject.Pop(); + Subject.ShouldNotContain(3); + }; + + static Stack Subject; + } + } +} \ No newline at end of file diff --git a/BDD/ConductOfCode/ConductOfCode/packages.config b/BDD/ConductOfCode/ConductOfCode/packages.config index 583e9a7..a344557 100644 --- a/BDD/ConductOfCode/ConductOfCode/packages.config +++ b/BDD/ConductOfCode/ConductOfCode/packages.config @@ -3,5 +3,7 @@ + + \ No newline at end of file