Exemplo n.º 1
0
        public void Execution_OnePhase()
        {
            // ARRANGE
            var disk = new TestDisk(DefaultDirs, DefaultFiles, DefaultManifests);

            Disk.Instance = disk;
            var activator = new TestActivator(1);

            ProcessActivator.Instance = activator;
            var args    = new[] { "Pkg1", "LOGLEVEL:Console" };
            var console = new StringWriter();

            SnAdmin.Output = console;

            // ACT
            var result = SnAdmin.Main(args);

            // ASSERT
            Assert.AreEqual(0, result);
            Assert.AreEqual(1, activator.ExePaths.Count);
            Assert.AreEqual(1, activator.Args.Count);
            Assert.IsTrue(activator.Args[0].Contains("Pkg1"));
            Assert.IsTrue(activator.Args[0].Contains("PHASE:0"));
        }
Exemplo n.º 2
0
        public void Help_PackageList()
        {
            // ARRANGE
            var disk = new TestDisk(DefaultDirs, DefaultFiles, DefaultManifests);

            Disk.Instance = disk;
            var activator = new TestActivator(1);

            ProcessActivator.Instance = activator;
            var args    = new[] { "-help" };
            var console = new StringWriter();

            SnAdmin.Output = console;

            // ACT
            SnAdmin.Main(args);

            // ASSERT
            var lines       = new List <string>();
            var consoleText = console.GetStringBuilder().ToString();

            using (var reader = new StringReader(consoleText))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    lines.Add(line);
                }
            }
            Assert.IsTrue(lines.Any(l => l.StartsWith("Usage:")));
            Assert.IsTrue(lines.Any(l => l.StartsWith("Available packages")));
            Assert.IsTrue(lines.Any(l => l.TrimStart().StartsWith("Pkg1")));
            Assert.IsTrue(lines.Any(l => l.TrimStart().StartsWith("Pkg2")));
            Assert.IsTrue(lines.Any(l => l.TrimStart().StartsWith("Pkg3")));
            Assert.AreEqual(0, activator.ExePaths.Count);
        }
Exemplo n.º 3
0
        public void Execution_ForceUnpack()
        {
            // ARRANGE
            var xml0 = new XmlDocument();

            //manifests.Add(@"Q:\WebApp1\Admin\Package1\manifest.xml", xml);
            xml0.LoadXml(@"<Package type='Product' level='Tool'>
  <Name>Sense/Net ECM</Name>
  <ReleaseDate>2016-12-21</ReleaseDate>
  <Description>|package description|</Description>
  <Steps>
    <Trace>Original message</Trace>
  </Steps>
</Package>");
            var xml1 = new XmlDocument();

            //manifests.Add(@"Q:\WebApp1\Admin\Package1\manifest.xml", xml);
            xml1.LoadXml(@"<Package type='Product' level='Tool'>
  <Name>Sense/Net ECM</Name>
  <ReleaseDate>2016-12-21</ReleaseDate>
  <Description>|package description|</Description>
  <Steps>
    <Trace>Overridden message</Trace>
  </Steps>
</Package>");

            var dirs = DefaultDirs.ToList();

            dirs.Add(@"Q:\WebApp1\Admin\Package1");
            var files = DefaultFiles.ToList();

            files.Add(@"Q:\WebApp1\Admin\Package1.zip");
            files.Add(@"Q:\WebApp1\Admin\Package1\manifest.xml");
            var manifests = DefaultManifests.ToDictionary(x => x.Key, x => x.Value);

            manifests.Add(@"Q:\WebApp1\Admin\Package1.zip\manifest.xml", xml0);
            manifests.Add(@"Q:\WebApp1\Admin\Package1\manifest.xml", xml1);

            var disk = new TestDisk(dirs, files, manifests);

            Disk.Instance = disk;
            var activator = new TestActivator(1);

            ProcessActivator.Instance = activator;
            var unpacker = new TestUnpacker();

            Unpacker.Instance = unpacker;
            var args    = new[] { "Package1", "LOGLEVEL:Console" };
            var console = new StringWriter();

            SnAdmin.Output = console;

            // ACT
            var result = SnAdmin.Main(args);

            // ASSERT
            var consoleText  = console.GetStringBuilder().ToString();
            var traceMessage = disk.Manifests[@"Q:\WebApp1\Admin\Package1\manifest.xml"].SelectSingleNode("//Trace")?.InnerText ?? "[null]";

            Assert.AreEqual(0, result);
            Assert.AreEqual("Original message", traceMessage);

            Assert.IsTrue(consoleText.Contains("Old files and directories are deleted."));
            Assert.IsTrue(consoleText.Contains("Extracting ..."));

            Assert.AreEqual(1, activator.ExePaths.Count);
            Assert.AreEqual(1, activator.Args.Count);
            Assert.IsTrue(activator.Args[0].Contains("Package1"));
            Assert.IsTrue(activator.Args[0].Contains("PHASE:0"));
        }