public void IncludesCompileConfigurationDirectory(string directory, string configuration, int expectedPaths)
        {
            var config = new BuildToolsConfig
            {
                Images = new ImageResize
                {
                    ConditionalDirectories = new Dictionary <string, IEnumerable <string> >
                    {
                        { directory, new[] { Path.Combine(ConfigPath, "images", directory) } },
                        { "Fake", new[] { Path.Combine(Environment.CurrentDirectory, "images", "Fake") } },
                    },
                    Directories = new List <string>
                    {
                        "images"
                    }
                }
            };

            var paths = ImageSearchUtil.GetSearchPaths(config, Platform.Android, configuration, ConfigPath);

            Assert.Equal(expectedPaths, paths.Count());
            Assert.Contains(paths, p => p == Path.Combine(ConfigPath, "images"));
            if (expectedPaths > 1)
            {
                Assert.Contains(paths, p => p == Path.Combine(ConfigPath, "images", directory));
            }
        }
Exemplo n.º 2
0
        // This needs the proper IntermediateOutputPath
        public static IEnumerable <OutputImage> GetGeneratedResources(string buildToolsConfigPath, string projectDirectory, string buildConfiguration, string intermediateOutputDirectory, Platform platform, ILog logger = null)
        {
            if (!File.Exists(buildToolsConfigPath))
            {
                return(Array.Empty <OutputImage>());
            }

            var buildConfig = new BuildConfiguration(projectDirectory, intermediateOutputDirectory, platform, logger);
            ImageCollectionGeneratorBase generator = platform switch
            {
                Platform.Android => new AndroidImageCollectionGenerator(buildConfig),
                Platform.iOS => new AppleImageCollectionGenerator(buildConfig),
                Platform.macOS => new AppleImageCollectionGenerator(buildConfig),
                Platform.TVOS => new AppleImageCollectionGenerator(buildConfig),
                _ => null
            };

            if (generator is null)
            {
                return(Array.Empty <OutputImage>());
            }

            var buildToolsConfig = ConfigHelper.GetConfig(buildToolsConfigPath);

            generator.SearchFolders = ImageSearchUtil.GetSearchPaths(buildToolsConfig, platform, buildConfiguration, buildToolsConfigPath);
            generator.Execute();
            return(generator.Outputs);
        }
    }
        public void PropertyHandlesDirectoryPathWithBackSlash()
        {
            var config = new BuildToolsConfig
            {
                Images = new ImageResize
                {
                    ConditionalDirectories = new Dictionary <string, IEnumerable <string> >(),
                    Directories            = new List <string>
                    {
                        @"images\test"
                    }
                }
            };

            var paths = ImageSearchUtil.GetSearchPaths(config, Platform.Android, "Debug", ConfigPath);

            Assert.Single(paths);
            Assert.Contains(paths, p => p == Path.Combine(ConfigPath, "images", "test"));
        }
        public void LogsAndRemovesPathsNotPresent()
        {
            var fakePath = Path.Combine(ConfigPath, "images", "Fake");
            var logger   = new Mock <ILog>();
            var config   = new BuildToolsConfig
            {
                Images = new ImageResize
                {
                    Directories = new List <string>
                    {
                        ConfigPath,
                        fakePath
                    }
                }
            };

            var paths = ImageSearchUtil.GetSearchPaths(config, Platform.Android, "Release", ConfigPath, logger: logger.Object);

            Assert.Single(paths);
            logger.Verify(x => x.LogWarning(It.IsAny <string>()));
        }
Exemplo n.º 5
0
 internal IEnumerable <string> GetSearchPaths(IBuildConfiguration config)
 {
     return(ImageSearchUtil.GetSearchPaths(config.Configuration, config.Platform, config.BuildConfiguration, ConfigurationPath, AdditionalSearchPaths, IgnoreDefaultSearchPaths));
 }