Beispiel #1
0
        public void MatchesValuesWithType()
        {
            var x = new AnyMatcher(typeof(int));

            Assert.True(x.Matches(5));
            Assert.False(x.Matches("foo"));
        }
Beispiel #2
0
        public void NonNullableNeverMatchesNull()
        {
            var x = new AnyMatcher(typeof(int));
            var y = AnyMatcher <int> .Default;

            Assert.False(x.Matches(null));
            Assert.False(y.Matches(null));
        }
        //TODO: refactor this away
        public RssDownloader ParseRssDownloader(XElement moduleElement)
        {
            string name               = moduleElement.Attribute("name").Value;
            string feedUrl            = moduleElement.Element("FeedUrl").Value;
            string torrentApplication = moduleElement.Element("TorrentApplicationPath").Value;

            List <IContentMatcher> matchers =
                HandlerXmlParser.ParseContentMatches(moduleElement.Element("MatchPatterns"));
            var matcher = new AnyMatcher(matchers);

            var downloader = new RssDownloader(name, torrentApplication, feedUrl, matcher);

            return(downloader);
        }
Beispiel #4
0
        public void EqualForSameType()
        {
            var x = new AnyMatcher(typeof(int));
            var y = new AnyMatcher(typeof(int));
            var z = new AnyMatcher(typeof(string));

            Assert.Same(x.ArgumentType, y.ArgumentType);
            Assert.Equal(x, y);
            Assert.True(((object)x).Equals(y));
            Assert.False(x.Equals(new object()));
            Assert.False(x.Equals((object)null));
            Assert.Equal(x.GetHashCode(), y.GetHashCode());
            Assert.NotEqual(x, z);
            Assert.False(((object)x).Equals(z));
        }
Beispiel #5
0
        public void NullableIntMatchesNull()
        {
            var x = new AnyMatcher(typeof(int?));

            Assert.True(x.Matches(null));
        }
Beispiel #6
0
        public void MatchesDerivedType()
        {
            var x = new AnyMatcher(typeof(Base));

            Assert.True(x.Matches(new Derived()));
        }