Ejemplo n.º 1
0
        public void RemoveDuplicates()
        {
            var fis = new List <FileInfo>
            {
                new FileInfo("z:\\a.txt"),
                new FileInfo("z:\\a.txt"),
                new FileInfo("z:\\a.txt"),
                new FileInfo("z:\\a.txt")
            };

            var fisD = File.Distinct(fis);

            Assert.AreEqual(1, fisD.Count);
            Assert.IsTrue(fisD.Any(f => f.FullName == "z:\\a.txt"));

            // nothing has changed
            Assert.AreEqual(4, fis.Count(f => f.FullName == "z:\\a.txt"));
        }