public static IProjectImageProvider ImplementGetProjectImage(string key, ProjectImageMoniker moniker)
        {
            return(IProjectImageProviderFactory.ImplementGetProjectImage((string k) => {
                if (k == key)
                {
                    return moniker;
                }

                return null;
            }));
        }
Exemple #2
0
        public void GetImageKey_SingleImageProviderReturningNull_ReturnsNull()
        {
            var project    = UnconfiguredProjectFactory.Create(capabilities: new[] { "CSharp" });
            var provider   = IProjectImageProviderFactory.ImplementGetProjectImage((key) => null);
            var aggregator = CreateInstance(project);

            aggregator.ImageProviders.Add(provider, "CSharp");

            var result = aggregator.GetProjectImage("key");

            Assert.Null(result);
        }
Exemple #3
0
        public void GetImageKey_SingleImageProviderReturningKey_ReturnsKey()
        {
            var moniker = new ProjectImageMoniker(Guid.NewGuid(), 0);

            var project    = UnconfiguredProjectFactory.Create(capabilities: new[] { "CSharp" });
            var provider   = IProjectImageProviderFactory.ImplementGetProjectImage((key) => moniker);
            var aggregator = CreateInstance(project);

            aggregator.ImageProviders.Add(provider, "CSharp");

            var result = aggregator.GetProjectImage("key");

            Assert.Same(moniker, result);
        }
Exemple #4
0
        public void GetImageKey_ManyImageProviders_ReturnsFirstThatReturnsKey()
        {
            var moniker = new ProjectImageMoniker(Guid.NewGuid(), 0);

            var project    = UnconfiguredProjectFactory.Create();
            var provider1  = IProjectImageProviderFactory.ImplementGetProjectImage((key) => null);
            var provider2  = IProjectImageProviderFactory.ImplementGetProjectImage((key) => moniker);
            var aggregator = CreateInstance(project);

            aggregator.ImageProviders.Add(provider1, orderPrecedence: 0);
            aggregator.ImageProviders.Add(provider2, orderPrecedence: 10);

            var result = aggregator.GetProjectImage("key");

            Assert.Same(moniker, result);
        }
Exemple #5
0
        public void GetImageKey_ManyImageProviders_ReturnsFirstThatReturnsKey()
        {
            ProjectImageMoniker moniker = new ProjectImageMoniker(Guid.NewGuid(), 0);

            var unconfiguredProject = UnconfiguredProjectFactory.Create(capabilities: new[] { "CSharp" });
            var provider1           = IProjectImageProviderFactory.ImplementGetProjectImage((key) => null);
            var provider2           = IProjectImageProviderFactory.ImplementGetProjectImage((key) => moniker);
            var aggregator          = CreateInstance(unconfiguredProject);

            aggregator.ImageProviders.Add(provider1, "CSharp", 0);
            aggregator.ImageProviders.Add(provider2, "CSharp", 10);

            var result = aggregator.GetProjectImage("key");

            Assert.Same(moniker, result);
        }
Exemple #6
0
        public void GetImageKey_ManyImageProviderReturningKey_ReturnsFirstByOrder()
        {
            var moniker1 = new ProjectImageMoniker(Guid.NewGuid(), 0);
            var moniker2 = new ProjectImageMoniker(Guid.NewGuid(), 0);

            var project    = UnconfiguredProjectFactory.Create(capabilities: new[] { "CSharp" });
            var provider1  = IProjectImageProviderFactory.ImplementGetProjectImage((key) => moniker1);
            var provider2  = IProjectImageProviderFactory.ImplementGetProjectImage((key) => moniker2);
            var aggregator = CreateInstance(project);

            aggregator.ImageProviders.Add(provider2, "CSharp", 0);  // Lowest
            aggregator.ImageProviders.Add(provider1, "CSharp", 10); // Highest

            var result = aggregator.GetProjectImage("key");

            Assert.Same(moniker1, result);
        }