Example #1
0
        public void delegates_can_be_passed_as_first_order_functions()
        {
            var areSimilar = new AreSimilarWithNamedDelegate();

            var actual = areSimilar.Check(
                new List <string> {
                "one", "two", "three"
            },
                new List <string> {
                "uno", "due", "e tre"
            },
                new ComparisonDelegate(StringComparators.CompareLength));

            actual.Should().BeTrue();
        }
Example #2
0
        public void anonymous_delegates_can_be_defined_inline()
        {
            var areSimilar = new AreSimilarWithNamedDelegate();

            var actual = areSimilar.Check(
                new List <string> {
                "one", "two", "three"
            },
                new List <string> {
                "uno", "due", "e tre"
            },
                delegate(string s1, string s2) { return(s1.Length == s2.Length); });

            actual.Should().BeTrue();
        }
Example #3
0
        public void lambda_expressions_are_an_alternative_syntax_for_anonymous_delegates()
        {
            var areSimilar = new AreSimilarWithNamedDelegate();

            var actual = areSimilar.Check(
                new List <string> {
                "one", "two", "three"
            },
                new List <string> {
                "uno", "due", "e tre"
            },
                (s1, s2) => s1.Length == s2.Length);

            actual.Should().BeTrue();
        }