Esempio n. 1
0
        public void AgeFilterStrategyTestRobust()
        {
            List <VirtualFileInfo> files = new List <VirtualFileInfo>()
            {
                new VirtualFileInfo(@"C:\foo\really_old.txt")
                {
                    CreationTime = DateTime.Now.AddYears(-101), LastWriteTime = DateTime.Now.AddYears(-101)
                },
                new VirtualFileInfo(@"C:\foo\in_the_future.txt")
                {
                    CreationTime = DateTime.Now.AddDays(3), LastWriteTime = DateTime.Now.AddDays(3)
                }
            };

            AgeFilterStrategy filter = new AgeFilterStrategy();

            // over 100 years old
            IList <VirtualFileInfo> results = filter.Filter(files, "cdate>36500d");

            Assert.AreEqual(1, results.Count);
            Assert.IsTrue(results.Contains(files[0]));

            // future-dated file: last modified by a DeLorean-riding scientist?
            results = filter.Filter(files, "mdate <= 3d");
            Assert.AreEqual(0, results.Count);
        }
Esempio n. 2
0
        public void AgeFilterStrategyTest()
        {
            List <VirtualFileInfo> files = new List <VirtualFileInfo>()
            {
                new VirtualFileInfo(@"C:\foo\bar.txt")
                {
                    CreationTime = DateTime.Now, LastWriteTime = DateTime.Now
                },
                new VirtualFileInfo(@"C:\foo\baz.txt")
                {
                    CreationTime = DateTime.Now.AddDays(-1), LastWriteTime = DateTime.Now
                },
                new VirtualFileInfo(@"C:\foo\buz.txt")
                {
                    CreationTime = DateTime.Now.AddHours(-12).AddMilliseconds(-1), LastWriteTime = DateTime.Now
                }
            };

            AgeFilterStrategy       filter  = new AgeFilterStrategy();
            IList <VirtualFileInfo> results = filter.Filter(files, "cdate > 12h");

            // should match two older files based on create date
            Assert.AreEqual(2, results.Count);
            Assert.IsTrue(results.Contains(files[1]));
            Assert.IsTrue(results.Contains(files[2]));

            // should match all three using date last modified
            results = filter.Filter(files, "mdate<=10s");
            Assert.AreEqual(3, results.Count);
        }