Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Machine.Specifications (MSpec) | ||
|
||
* Dependencies: - | ||
* NuGet: https://www.nuget.org/packages/Machine.Specifications/ | ||
* Source: https://github.com/machine/machine.specifications |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<int>(); | ||
}; | ||
|
||
It should_have_no_elements = () => Subject.ShouldBeEmpty(); | ||
It should_throw_an_exception_when_calling_pop = () => Catch.Exception(() => Subject.Pop()).ShouldBeOfExactType<InvalidOperationException>(); | ||
It should_throw_an_exception_when_calling_peek = () => Catch.Exception(() => Subject.Peek()).ShouldBeOfExactType<InvalidOperationException>(); | ||
|
||
static Stack<int> Subject; | ||
} | ||
|
||
[Subject(typeof(Stack<>))] | ||
public class When_not_empty | ||
{ | ||
Establish context = () => | ||
{ | ||
Subject = new Stack<int>(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<int> Subject; | ||
} | ||
} | ||
} |
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