Ejemplo n.º 1
0
        public void SimpleIntersectionWithDuplicates()
        {
            var fisA = new List <FileInfo>
            {
                new FileInfo("z:\\a.txt"),
                new FileInfo("z:\\b.txt"),
                new FileInfo("z:\\b.txt")
            };
            var fisB = new List <FileInfo>
            {
                new FileInfo("z:\\b.txt"),
                new FileInfo("z:\\b.txt"),
                new FileInfo("z:\\c.txt")
            };

            var fisI = File.Intersection(fisA, fisB);

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

            // nothing has changed
            Assert.AreEqual(3, fisA.Count);
            Assert.IsTrue(fisA.Any(f => f.FullName == "z:\\a.txt"));
            Assert.AreEqual(2, fisA.Count(f => f.FullName == "z:\\b.txt"));

            Assert.AreEqual(3, fisB.Count);
            Assert.IsTrue(fisB.Any(f => f.FullName == "z:\\b.txt"));
            Assert.AreEqual(2, fisB.Count(f => f.FullName == "z:\\b.txt"));
        }
Ejemplo n.º 2
0
        public void IntersectionBothNull()
        {
            var fisI = File.Intersection(null, null);

            Assert.IsInstanceOf <List <FileInfo> >(fisI);
            Assert.AreEqual(0, fisI.Count);
        }
Ejemplo n.º 3
0
        public void IntersectionSecondListIsNullList()
        {
            var fis = new List <FileInfo>
            {
                new FileInfo("z:\\a.txt"),
                new FileInfo("z:\\b.txt")
            };

            var fisI = File.Intersection(fis, null);

            Assert.IsInstanceOf <List <FileInfo> >(fisI);
            Assert.AreEqual(0, fisI.Count);

            Assert.AreEqual(2, fis.Count);
            Assert.IsTrue(fis.Any(f => f.FullName == "z:\\a.txt"));
            Assert.IsTrue(fis.Any(f => f.FullName == "z:\\b.txt"));
        }
Ejemplo n.º 4
0
        public void NoIntersectionAtAll()
        {
            var fisA = new List <FileInfo>
            {
                new FileInfo("z:\\a.txt")
            };
            var fisB = new List <FileInfo>
            {
                new FileInfo("z:\\b.txt")
            };

            var fisI = File.Intersection(fisA, fisB);

            Assert.AreEqual(0, fisI.Count);
            Assert.IsInstanceOf <List <FileInfo> >(fisI);

            // nothing has changed
            Assert.AreEqual(1, fisA.Count);
            Assert.IsTrue(fisA.Any(f => f.FullName == "z:\\a.txt"));

            Assert.AreEqual(1, fisB.Count);
            Assert.IsTrue(fisB.Any(f => f.FullName == "z:\\b.txt"));
        }
Ejemplo n.º 5
0
        public void ExactIntersection()
        {
            var fisA = new List <FileInfo>
            {
                new FileInfo("z:\\a.txt")
            };
            var fisB = new List <FileInfo>
            {
                new FileInfo("z:\\a.txt")
            };

            var fisI = File.Intersection(fisA, fisB);

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

            // nothing has changed
            Assert.AreEqual(1, fisA.Count);
            Assert.IsTrue(fisA.Any(f => f.FullName == "z:\\a.txt"));

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