示例#1
0
        public void ObtainSpecificVersionWithoutFallback()
        {
            // Given
            HashProvider   hp     = new HashProvider();
            IConfiguration config = new TestConfiguration();

            config.Settings.HelpDirectory = "Help";
            HelpBuilderService buildService = new HelpBuilderService(config, hp);
            HelpService        helpService  = new HelpService(buildService);

            string myFakePluginId = Guid.NewGuid().ToString("B");

            CreateFakeHelp(buildService, myFakePluginId, new Version[] { new Version("1.0.0"), new Version("2.0.0") }, new string[] { "fr-FR", "fr", "en" });
            buildService.CreateOrUpdateBuilds();

            // When
            using (Stream helpPackage = helpService.GetHelpPackage(myFakePluginId, new Version("1.0.0"), "fr-FR"))
            {
                // Then
                Assert.That(helpPackage, Is.Not.Null);
                Assert.That(helpPackage.CanRead, Is.True);

                CheckHelpPackage(helpPackage, (m) =>
                {
                    Assert.That(m.Culture, Is.EqualTo("fr-FR"));
                    Assert.That(m.PluginId, Is.EqualTo(myFakePluginId));
                    Assert.That(m.Version, Is.EqualTo("1.0.0"));
                });
            }
        }
        public void CreateOrUpdateAllBuildsAvailableInSource()
        {
            // Given
            HashProvider   hp     = new HashProvider();
            IConfiguration config = new TestConfiguration();

            config.Settings.HelpDirectory = "Help";

            HelpBuilderService buildService = new HelpBuilderService(config, hp);

            DirectoryInfo frHelpDir = buildService.SourceDirectory.CreateSubdirectory(Path.Combine(Guid.NewGuid().ToString("B"), "1.0.0", "fr"));

            frHelpDir.Create();

            DirectoryInfo enHelpDir = frHelpDir.Parent.CreateSubdirectory("en");

            enHelpDir.Create();

            File.Create(Path.Combine(frHelpDir.FullName, "helpContent.txt")).Dispose();
            File.Create(Path.Combine(enHelpDir.FullName, "helpContent.txt")).Dispose();

            // When
            buildService.CreateOrUpdateBuilds();

            // Then
            DirectoryInfo pluginBuildDir = buildService.BuildsDirectory.EnumerateDirectories(frHelpDir.Parent.Parent.Name).FirstOrDefault();

            Assert.That(pluginBuildDir, Is.Not.Null);

            DirectoryInfo versionBuildDir = pluginBuildDir.EnumerateDirectories(frHelpDir.Parent.Name).FirstOrDefault();

            Assert.That(versionBuildDir, Is.Not.Null);

            DirectoryInfo frBuildDir = versionBuildDir.EnumerateDirectories("fr").FirstOrDefault();
            DirectoryInfo enBuildDir = versionBuildDir.EnumerateDirectories("en").FirstOrDefault();

            Assert.That(frBuildDir, Is.Not.Null);
            Assert.That(enBuildDir, Is.Not.Null);

            Assert.That(frBuildDir.EnumerateFiles().Any(f => f.Name == "hash"));
            Assert.That(frBuildDir.EnumerateFiles().Any(f => f.Name == "package.zip"));
            Assert.That(enBuildDir.EnumerateFiles().Any(f => f.Name == "hash"));
            Assert.That(enBuildDir.EnumerateFiles().Any(f => f.Name == "package.zip"));
        }
示例#3
0
        public void ObtainSpecificVersionThatDoesNotExists()
        {
            // Given
            HashProvider   hp     = new HashProvider();
            IConfiguration config = new TestConfiguration();

            config.Settings.HelpDirectory = "Help";
            HelpBuilderService buildService = new HelpBuilderService(config, hp);
            HelpService        helpService  = new HelpService(buildService);

            string myFakePluginId = Guid.NewGuid().ToString("B");

            CreateFakeHelp(buildService, myFakePluginId, new Version[] { new Version("1.0.0") }, new string[] { "fr" });
            buildService.CreateOrUpdateBuilds();

            // When
            using (Stream helpPackage = helpService.GetHelpPackage(myFakePluginId, new Version("3.0.0"), "en-US"))
            {
                // Then
                Assert.That(helpPackage, Is.Null);
            }
        }