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

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

            ProcessActivator.Instance = activator;
            var args    = new[] { "MissingPackage", "-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("Package does not exist: MissingPackage")));
            Assert.AreEqual(0, activator.ExePaths.Count);
        }
Esempio n. 2
0
        public void Help_PackageDetails()
        {
            // ARRANGE
            var disk = new TestDisk(DefaultDirs, DefaultFiles, DefaultManifests);

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

            ProcessActivator.Instance = activator;
            var args    = new[] { "Pkg1", "-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("|package description|")));
            Assert.IsTrue(lines.Any(l => l.TrimStart().StartsWith("traceMessage") && l.Contains("|parameter description|")));
            Assert.IsTrue(lines.Any(l => l.TrimStart().StartsWith("Default: |default value|")));
            Assert.AreEqual(0, activator.ExePaths.Count);
        }
Esempio n. 3
0
        public void Execution_ThreePhases()
        {
            // ARRANGE
            var disk = new TestDisk(DefaultDirs, DefaultFiles, DefaultManifests);

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

            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(3, activator.ExePaths.Count);
            Assert.AreEqual(3, activator.Args.Count);
            Assert.IsTrue(activator.Args[0].Contains("Pkg1"));
            Assert.IsTrue(activator.Args[0].Contains("PHASE:0"));
            Assert.IsTrue(activator.Args[1].Contains("Pkg1"));
            Assert.IsTrue(activator.Args[1].Contains("PHASE:1"));
            Assert.IsTrue(activator.Args[2].Contains("Pkg1"));
            Assert.IsTrue(activator.Args[2].Contains("PHASE:2"));
        }
Esempio n. 4
0
        public void Execution_Unpack()
        {
            // ARRANGE
            var xml = new XmlDocument();

            //manifests.Add(@"Q:\WebApp1\Admin\Package1\manifest.xml", xml);
            xml.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 files = DefaultFiles.ToList();

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

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

            var disk = new TestDisk(DefaultDirs, 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();

            Assert.AreEqual(0, result);

            Assert.IsTrue(disk.Manifests.ContainsKey(@"Q:\WebApp1\Admin\Package1\manifest.xml"));
            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"));
        }