Example #1
0
        public void PatternMatcher_Without_Output()
        {
            //Assert
            List <int>     integers       = new List <int>();
            List <string>  strings        = new List <string>();
            List <double>  floats         = new List <double>();
            PatternMatcher patternMatcher = new PatternMatcher().
                                            Case <string>(str => strings.Add(str)).
                                            Case <double>(dbl => floats.Add(dbl)).
                                            Case <int>(integer => integers.Add(integer)).
                                            Default(x => { throw new NotImplementedException(); });

            //Act
            patternMatcher.Match(10);
            patternMatcher.Match("string");
            patternMatcher.Match(3.14);

            //Assert
            Assert.AreEqual(1, integers.Count());
            Assert.AreEqual(1, strings.Count());
            Assert.AreEqual(1, floats.Count());
        }