Exemplo n.º 1
0
        public void CandidateAssemblies_ReturnsLibrariesReferencingAnyMvcAssembly()
        {
            // Arrange
            var manager = new Mock <ILibraryManager>();

            manager.Setup(f => f.GetReferencingLibraries(It.IsAny <string>()))
            .Returns(Enumerable.Empty <ILibraryInformation>());
            manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc.Core"))
            .Returns(new[] { CreateLibraryInfo("Foo") });
            manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc.ModelBinding"))
            .Returns(new[] { CreateLibraryInfo("Bar") });
            manager.Setup(f => f.GetReferencingLibraries("Microsoft.AspNet.Mvc"))
            .Returns(new[] { CreateLibraryInfo("Baz") });
            var provider = new DefaultAssemblyProvider(manager.Object);

            // Act
            var candidates = provider.GetCandidateLibraries();

            // Assert
            Assert.Equal(new[] { "Baz", "Foo", "Bar" }, candidates.Select(a => a.Name));
        }
Exemplo n.º 2
0
        public void CandidateAssemblies_IgnoresMvcAssemblies()
        {
            // Arrange
            var manager = new Mock <ILibraryManager>();

            manager.Setup(f => f.GetReferencingLibraries(It.IsAny <string>()))
            .Returns(new[]
            {
                CreateLibraryInfo("Microsoft.AspNet.Mvc.Core"),
                CreateLibraryInfo("Microsoft.AspNet.Mvc"),
                CreateLibraryInfo("Microsoft.AspNet.Mvc.ModelBinding"),
                CreateLibraryInfo("SomeRandomAssembly"),
            })
            .Verifiable();
            var provider = new DefaultAssemblyProvider(manager.Object);

            // Act
            var candidates = provider.GetCandidateLibraries();

            // Assert
            Assert.Equal(new[] { "SomeRandomAssembly" }, candidates.Select(a => a.Name));
        }