Пример #1
0
        public void WebArtifactBuilder_Build_CreatesDirectoryWithXmlHtmlAndLogFiles()
        {
            using (var appDataFolder = new ArtifactFolder())
            {
                var preferences = CreatePreferences(appDataFolder.Path);
                preferences.Set(Preference.WebGenCopyHtml, true);
                preferences.Set(Preference.WebGenCopyFAHlog, true);

                string cacheDirectory = preferences.Get <string>(Preference.CacheDirectory);
                Directory.CreateDirectory(cacheDirectory);

                var slots = CreateSlotModelCollection();
                foreach (var slot in slots)
                {
                    using (var stream = File.Create(Path.Combine(cacheDirectory, $"{slot.Name}-log.txt")))
                        using (var writer = new StreamWriter(stream))
                        {
                            writer.WriteLine(slot.Name);
                        }
                }

                using (var artifacts = new ArtifactFolder())
                {
                    var artifactBuilder = new WebArtifactBuilder(null, preferences, artifacts.Path);
                    var path            = artifactBuilder.Build(slots);

                    Assert.IsTrue(Directory.EnumerateFiles(path).Any(x => Path.GetExtension(x) == ".xml"));
                    Assert.IsTrue(Directory.EnumerateFiles(path).Any(x => Path.GetExtension(x) == ".html"));
                    Assert.IsTrue(Directory.EnumerateFiles(path).Any(x => Path.GetExtension(x) == ".txt"));
                }
            }
        }
Пример #2
0
        public void WebArtifactBuilder_Build_CreatesDirectoryWithXmlAndHtmlFiles()
        {
            var preferences = CreatePreferences();

            preferences.Set(Preference.WebGenCopyHtml, true);

            var slots = CreateSlotModelCollection();

            using (var artifacts = new ArtifactFolder())
            {
                var artifactBuilder = new WebArtifactBuilder(null, preferences, artifacts.Path);
                var path            = artifactBuilder.Build(slots);

                Assert.IsTrue(Directory.EnumerateFiles(path).Any(x => Path.GetExtension(x) == ".xml"));
                Assert.IsTrue(Directory.EnumerateFiles(path).Any(x => Path.GetExtension(x) == ".html"));
                Assert.IsFalse(Directory.EnumerateFiles(path).Any(x => Path.GetExtension(x) == ".txt"));
            }
        }
Пример #3
0
        public void WebArtifactDeployment_Deploy_DeploysArtifactsToTargetPath(bool copyXml, bool copyHtml, bool copyLog, int expected)
        {
            using (var appDataFolder = new ArtifactFolder())
            {
                var preferences = CreatePreferences(appDataFolder.Path);
                preferences.Set(Preference.WebGenCopyXml, copyXml);
                preferences.Set(Preference.WebGenCopyHtml, copyHtml);
                preferences.Set(Preference.WebGenCopyFAHlog, copyLog);

                string cacheDirectory = preferences.Get <string>(Preference.CacheDirectory);
                Directory.CreateDirectory(cacheDirectory);

                var slots = CreateSlotModelCollection();
                foreach (var slot in slots)
                {
                    using (var stream = File.Create(Path.Combine(cacheDirectory, $"{slot.Name}-log.txt")))
                        using (var writer = new StreamWriter(stream))
                        {
                            writer.WriteLine(slot.Name);
                        }
                }

                using (var artifacts = new ArtifactFolder())
                {
                    var artifactBuilder = new WebArtifactBuilder(null, preferences, artifacts.Path);
                    var path            = artifactBuilder.Build(slots);

                    using (var deployFolder = new ArtifactFolder())
                    {
                        preferences.Set(Preference.WebDeploymentRoot, deployFolder.Path);
                        var deployment = WebArtifactDeployment.Create(WebDeploymentType.Path, null, preferences);
                        deployment.Deploy(path);

                        Assert.AreEqual(expected, Directory.GetFiles(deployFolder.Path).Length);
                    }
                }
            }
        }