Example #1
0
        public void Matches_should_detect_multiple_interface_enumerators()
        {
            var subj = new HaveKeyMatcher <string>("hello");

            var items = new MCollection();

            Assert.True(subj.Matches(items));
        }
Example #2
0
        public void Matches_should_detect_non_matching_key_and_value_list()
        {
            var subj = new HaveKeyMatcher <string>("hello");

            Assert.True(subj.Matches(new List <KeyValuePair <string, int> > {
                { new KeyValuePair <string, int>("hello", 420) }
            }));
        }
Example #3
0
        public void Matches_should_detect_non_matching_key_and_value_nominal()
        {
            var subj = new HaveKeyMatcher <string>("hello");

            Assert.False(subj.Matches(new Dictionary <string, int> {
                { "nope", 420 }
            }));
        }
Example #4
0
        public void Matches_should_detect_key_nominal()
        {
            var subj = new HaveKeyMatcher <string>("hello");

            Assert.True(subj.Matches(new Dictionary <string, int> {
                { "hello", 420 }
            }));
        }
Example #5
0
        public void Matches_should_detect_matching_groupings()
        {
            var subj = new HaveKeyMatcher <string>("hello");
            var groupings = new List <KeyValuePair <string, int> > {
                { new KeyValuePair <string, int>("hello", 420) }
            }.GroupBy(t => t.Key);

            Assert.True(subj.Matches(groupings));
        }
Example #6
0
        public void Matches_should_throw_on_type_without_keys()
        {
            var subj = new HaveKeyMatcher <string>("hello");

            try {
                subj.Matches(new ArrayList());
            } catch (AssertException e) {
                Assert.Equal("Can't assert that instance of `System.Collections.ArrayList' has keys because it doesn't support it.",
                             e.Message);
                Assert.Pass();
            }
        }