Created
March 31, 2011 07:40
-
-
Save ilkerde/895974 to your computer and use it in GitHub Desktop.
What do you expect? Fail or Pass? Me expects Fail!
This file contains hidden or 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
/* Question: | |
What do you expect from assertion below? Fail or Pass? | |
*/ | |
List<string> aList = new List<string> { "any" }; | |
List<string> anEmptyList = new List<string>(); | |
aList.ShouldContain(anEmptyList); // this currently passes! | |
/* | |
My opinion: above assertion should fail. My spec for this is: | |
*/ | |
public class when_a_list_contains_an_element_and_another_list_is_empty | |
{ | |
It should_fail_the__ShouldContains__assertion = | |
() => SpecException.ShouldBeOfType<SpecificationException>(); | |
Because of = | |
() => SpecException = Catch.Exception(() => AList.ShouldContain(AnotherList)); | |
Establish context = | |
() => | |
{ | |
Element = "An Element"; | |
AList = new List<string> {Element}; | |
AnotherList = new List<string>(); | |
}; | |
static Exception SpecException; | |
static List<string> AList; | |
static List<string> AnotherList; | |
static string Element; | |
} | |
/* | |
What do you think? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ilker,
this can be reduced to:
I would write this as two expression:
I think this separation is valid since the mathematical notation also distincts both cases and it would be good to communicate this in the specs. It also reads better in the error report (it might be the case that only one statement is broken).
Inhabited Sets might be a valid solution but I think Constructivism terms and arguments are not that widespread. ;-)