public void Distinct()
        {
            int[] numbers = new[] {1, 2, 1, 3, 4, 5, 5, 3};

            Assert.AreEqual(5, numbers.Distinct((a, b) => a == b).Count());

            Assert.AreEqual(new[] { 1, 2, 3, 4, 5 }, numbers.Distinct((a, b) => a == b).ToArray());
        }
Ejemplo n.º 2
0
        public void should_return_distinct_items()
        {
            var jedis = new[]
                            {
                                new Jedi("Mace Windu"),
                                new Jedi("Mace Windu"),
                                new Jedi("Luke Skywalker"),
                                new Jedi("Yoda"),
                                new Jedi("Yoda"),
                            };

            IEnumerable<Jedi> distinct = jedis.Distinct((j1, j2) => j1.Name == j2.Name);

            distinct.Count().ShouldBe(3);
        }
Ejemplo n.º 3
0
        public void ChecksumFXAssemblies()
        {
            var paths = new[]
            {
                typeof(object).GetTypeInfo().Assembly.Location,
                typeof(Enumerable).GetTypeInfo().Assembly.Location,
                typeof(Linq.Expressions.Expression).GetTypeInfo().Assembly.Location,
                typeof(ComponentModel.EditorBrowsableAttribute).GetTypeInfo().Assembly.Location,
                typeof(IEnumerable<>).GetTypeInfo().Assembly.Location,
                typeof(Text.Encoding).GetTypeInfo().Assembly.Location,
                typeof(Threading.Tasks.Task).GetTypeInfo().Assembly.Location,
                typeof(IO.MemoryMappedFiles.MemoryMappedFile).GetTypeInfo().Assembly.Location,
                typeof(Diagnostics.Debug).GetTypeInfo().Assembly.Location,
                typeof(ImmutableArray).GetTypeInfo().Assembly.Location,
                typeof(Text.RegularExpressions.Regex).GetTypeInfo().Assembly.Location,
                typeof(Threading.Tasks.ParallelLoopResult).GetTypeInfo().Assembly.Location,
            };

            foreach (string path in paths.Distinct())
            {
                using (var peStream = File.OpenRead(path))
                {
                    TestChecksumAndAuthenticodeSignature(peStream);
                }
            }
        }