public void FirstTest()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {@"c:\test.dll", new MockFileData(CreateAssembly(dependencies: new Dictionary<string, string>{{"Blah","1.0"},{"System","4.0.0.0"}}))}
                });

            var gacResolver = Substitute.For<IGacResolver>();
            string output;
            gacResolver.AssemblyExists(Arg.Any<String>(),out output).Returns(true);
            var grapher = new AssemblyReferenceGrapher(fileSystem, gacResolver);

            var graph = grapher.GenerateAssemblyReferenceGraph(new List<Regex>(), new ConcurrentBag<string>(fileSystem.AllPaths), false);
            Assert.AreEqual(3,graph.Vertices.Count());
        }
        public void CanDetectIncorrectVersion(bool checkAssemblyVersion, bool assemblyExists)
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {@"c:\test.dll", new MockFileData(CreateAssembly("Test", dependencies: new Dictionary<string, string> {{"Blah", "1.0.0.0"}, {"System", "4.0.0.0"}}))},
                    {@"c:\blah.dll", new MockFileData(CreateAssembly("Blah", version: "1.1.0.0", dependencies: new Dictionary<string, string> {{"System", "2.0.0.0"}}))}
                });

            var gacResolver = Substitute.For<IGacResolver>();
            string output;
            gacResolver.AssemblyExists(Arg.Any<String>(), out output).Returns(true);
            var grapher = new AssemblyReferenceGrapher(fileSystem, gacResolver);

            var graph = grapher.GenerateAssemblyReferenceGraph(new List<Regex>(), new List<Regex>(), new ConcurrentBag<string>(fileSystem.AllPaths), false, checkAssemblyVersion);
            Assert.AreEqual(5, graph.Vertices.Count());
            var assembly = graph.Vertices.First(v => v.AssemblyName.Name.Equals("Blah") && v.AssemblyName.Version.ToString().Equals("1.0.0.0"));
            Assert.AreEqual(assemblyExists, assembly.Exists);
        }
        public void MissingFileResultsInNodeWithExistEqualsFalse()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {@"c:\test.dll", new MockFileData(CreateAssembly(dependencies: new Dictionary<string, string> {{"Blah", "1.0"}, {"System", "4.0.0.0"}}))},
                });

            var gacResolver = Substitute.For<IGacResolver>();
            gacResolver.AssemblyExists("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null").Returns(true);
            var grapher = new AssemblyReferenceGrapher(fileSystem, gacResolver);

            var graph = grapher.GenerateAssemblyReferenceGraph(new List<Regex>(), new List<Regex>(), new ConcurrentBag<string>(fileSystem.AllPaths), false);
            Assert.AreEqual(3, graph.Vertices.Count());
            Assert.AreEqual(false, graph.Vertices.FirstOrDefault(v => v.AssemblyName.Name.Equals("Blah", StringComparison.OrdinalIgnoreCase)).Exists);
            Assert.AreEqual(1, graph.Vertices.Count(v => v.Exists == false));
        }
        public void CanDetectIncorrectCorFlags(bool sourceIs64Bit, bool dependencyIs64Bit, int vertexCount, int missingCount)
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {@"c:\test.dll", new MockFileData(CreateAssembly(dependencies: new Dictionary<string, string> {{"Blah", "1.0"}}, sixtyfourbit: sourceIs64Bit))},
                    {@"c:\blah.dll", new MockFileData(CreateAssembly("Blah",sixtyfourbit: dependencyIs64Bit))},
                });

            var gacResolver = Substitute.For<IGacResolver>();
            gacResolver.AssemblyExists(Arg.Any<String>()).Returns(false);
            var grapher = new AssemblyReferenceGrapher(fileSystem, gacResolver);
            var graph = grapher.GenerateAssemblyReferenceGraph(new List<Regex>(), new List<Regex>(), new ConcurrentBag<string>(fileSystem.AllPaths), false);
            Assert.AreEqual(vertexCount, graph.Vertices.Count());
            var missing = graph.Vertices.Where(v => !v.Exists);
            Assert.AreEqual(missingCount, missing.Count());
        }
        public void CanExcludeFileAndAllReferencesFromGraph()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
                {
                    {@"c:\test.dll", new MockFileData(CreateAssembly(dependencies: new Dictionary<string, string> {{"Blah", "1.0"}, {"System", "4.0.0.0"}}))},
                    {@"c:\test2.dll", new MockFileData(CreateAssembly("Test2",dependencies: new Dictionary<string, string> {{"Blah2", "1.0"}, {"Other", "4.0.0.0"}}))},
                });

            var gacResolver = Substitute.For<IGacResolver>();
            gacResolver.AssemblyExists(Arg.Any<String>()).Returns(true);
            var grapher = new AssemblyReferenceGrapher(fileSystem, gacResolver);
            var ignore = new List<Regex> { new Wildcard("test2") };
            var graph = grapher.GenerateAssemblyReferenceGraph(new List<Regex>(), ignore, new ConcurrentBag<string>(fileSystem.AllPaths), false);
            Assert.AreEqual(3, graph.Vertices.Count());
        }