public void TestAzureGetWithoutSlash()
        {
            downloader.Setup(m => m.DownloadPackageToDisk(It.Is<Uri>(u => u.ToString().StartsWith(@"https://test.blob.core.windows.net/container/large.rar")),
                                                          It.Is<bool>(b => b == false),
                                                          It.Is<string>(s => string.Equals(s, @"C:\Temp"))))
                                                          .Returns(@"c:\temp")
                                                          .Verifiable();
            var args = new BootStrapperArgs()
            {
                Get = "container/large.rar",
                LocalResource = @"C:\Temp",
                StorageConnection = this.validConnection
            };

            var manager = new BootStrapperManager(logger.Object, downloader.Object, runner.Object, unzipper.Object);
            manager.Start(args);

            downloader.VerifyAll();
        }
        internal static void Main(string[] args)
        {
            try
            {
                // Expand first and then bind to Args
                var expanded = args.Select(a => parser.ParseArguments(a)).ToArray();

                var config = Args.Configuration.Configure<CommandArgs>();

                var cmds = config.AsFluent()
                    .UsingStringComparer(StringComparer.InvariantCultureIgnoreCase)
                    .UsingSwitchDelimiter("/")
                    .Initialize()
                    .CreateAndBind(expanded);

                if (args.Length < 1 || args.Length == 1 && cmds.ShowHelp)
                {
                    var help = new HelpProvider();
                    var commandsHelp = help.GenerateModelHelp<CommandArgs>(config);

                    var formatter = new Args.Help.Formatters.ConsoleHelpFormatter();
                    formatter.WriteHelp(commandsHelp, Console.Out);

                    return;
                }

                // TODO: Research for a better way to validate parameters with Args
                try
                {
                    ValidateArgs(cmds);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine();
                    Console.WriteLine("Try bootstrapper -help for more information");
                }

                //simple mapping
                var bootArgs = new BootStrapperArgs
                    {
                        Args = cmds.Args,
                        Block = cmds.Block,
                        EnableSystemProfile = cmds.EnableSystemProfile,
                        Get = cmds.Get,
                        LocalResource = cmds.LocalResource,
                        Overwrite = cmds.Overwrite,
                        Put = cmds.Put,
                        Run = cmds.Run,
                        RunAlways = cmds.RunAlways,
                        StorageConnection = cmds.StorageConnection,
                        Unzip = !String.IsNullOrWhiteSpace(cmds.Unzip),
                        UnzipTarget = cmds.Unzip
                    };

                //default to trace logger
                var logger = new TraceLogger();
                var manager = new BootStrapperManager(logger, new PackageDownloader(logger), new PackageRunner(logger),
                                                      new PackageUnzipper(logger), new PackageUploader(logger),
                                                      new PackageZipper(logger));

                manager.Start(bootArgs);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());

                // TODO: Push error to blob storage?
            }
        }
        public void TestSimpleGet()
        {
            var uri = new Uri(@"http://contoso.com/installer.msi");

            downloader.Setup(m => m.DownloadPackageToDisk(uri, false, @"C:\Temp"))
                      .Returns(@"c:\temp");

            var args = new BootStrapperArgs()
            {
                Get = uri.ToString(),
                LocalResource = @"C:\Temp"
            };

            var manager = new BootStrapperManager(logger.Object, downloader.Object, runner.Object, unzipper.Object);
            manager.Start(args);

            downloader.VerifyAll();
        }
        public void TestUnzip()
        {
            downloader.Setup(m => m.DownloadPackageToDisk(It.IsAny<Uri>(), It.IsAny<bool>(), It.IsAny<string>())).Returns(@"C:\Temp\testing.zip").Verifiable();

            unzipper.Setup(m => m.Unzip(It.Is<string>(s => string.Equals(s, @"C:\Temp\testing.zip")), It.Is<string>(s => s == @"C:\Temp"), It.Is<bool>(b => b == false))).Verifiable();

            var args = new BootStrapperArgs()
            {
                Get = "http://contoso.net/downloads/testing.zip",
                LocalResource = @"C:\Temp", // when run on bootstrapper.exe, this is assiged to whatever unziptarget is
                UnzipTarget = @"C:\Temp",
                Unzip = true
            };

            var manager = new BootStrapperManager(logger.Object, downloader.Object, runner.Object, unzipper.Object);
            manager.Start(args);

            unzipper.VerifyAll();
        }