public void testZipperUnexpectedException()
 {
     ZipMakerMock unknownExceptionZipperMaker = new ZipMakerMock();
     unknownExceptionZipperMaker.setUnkownExceptionStatus(true);
     DirectoryZipper unhandledExceptionZipper = new DirectoryZipper(unknownExceptionZipperMaker, new InstallerDirectory("FilePath", new FileManagerMock()));
     unhandledExceptionZipper.zipInstallerFile("PublicSafetyOne Client","thisIsThePlace");
 }
 public void testDoesZipperDestinationFileExist()
 {
     ZipMakerMock destinationFileExistsAlready = new ZipMakerMock();
     destinationFileExistsAlready.setDestinationFileName("defendIt");
     DirectoryZipper fileAlreadyExists = new DirectoryZipper(destinationFileExistsAlready,new InstallerDirectory("FilePAth",new FileManagerMock()));
     fileAlreadyExists.zipInstallerFile("PublicSafetyOne Client","defendIt");
 }
 public void testDoesCreateZipperDestinationFileExist()
 {
     DirectoryZipper fileAlreadyExists = new DirectoryZipper(new ZipMakerMock(), new InstallerDirectory("FilePath", new FileManagerMock()));
     string destinationFilePath = fileAlreadyExists.zipInstallerFile("PublicSafetyOne Client","defendIt");
     Assert.AreEqual(@"FilePath\defendIt",destinationFilePath);
 }
        static void Main(string[] args)
        {
            try
            {
                Console.Clear();
                Console.WriteLine(
                    "=======================================================================================");
                Console.WriteLine("WELCOME TO RICHARD'S CLIENT BINARY ZIP FILE TOOL");
                Console.WriteLine();

                string productVersion = "";
                DirectoryZipper zipper = new DirectoryZipper(new ConcerteZipMaker(),
                    new InstallerDirectory(ConfigurationSettings.AppSettings["PUBLICSAFETYINSTALLPATH"],
                        new ConcreteFileManager(ConfigurationSettings.AppSettings["PUBLICSAFETYINSTALLPATH"])));

                Console.WriteLine("PLEASE WRITE ENTER THE PRODUCT VERSION AND PRESS ENTER");
                productVersion = Console.ReadLine();
                if (productVersionIsNotMismatched(productVersion))
                {
                    Console.WriteLine();
                    Console.WriteLine("ZIPPING UP FILES");

                    string clientZipName = ConfigurationSettings.AppSettings["ClientBinariesSaveFileName"] +
                                           productVersion + ".zip";

                    string clientInstallerLocation =
                        zipper.zipInstallerFile(ConfigurationSettings.AppSettings["PUBLICSAFETYCLIENT"],
                            clientZipName);
                    ZipDetails clientInstallerZipDetails = new ZipDetails()
                    {
                        ProductVersion = productVersion,
                        ZipName =
                            clientZipName,
                        ZipLocation = clientInstallerLocation
                    };
                    Console.WriteLine(clientInstallerZipDetails.ZipLocation);
                    Console.WriteLine("CLIENT ZIPPED AT LOCATION : " + clientInstallerZipDetails.ZipLocation);

                    string launcherZipName = ConfigurationSettings.AppSettings["LauncherBinariesSaveFileName"] +
                                             productVersion + ".zip";
                    string launcherInstallerLocation =
                        zipper.zipInstallerFile(ConfigurationSettings.AppSettings["PUBLICSAFETYLAUNCHER"],
                            launcherZipName);
                    ZipDetails launcherZipDetails = new ZipDetails()
                    {
                        ProductVersion = productVersion,
                        ZipLocation = launcherInstallerLocation,
                        ZipName = launcherZipName
                    };

                    Console.WriteLine("LAUNCHER ZIPPED AT LOCATION : " + launcherZipDetails.ZipLocation);
                    Console.WriteLine();

                    Console.WriteLine(
                        "DO YOU WANT TO UPLOAD THIS FILE TO THE BLOB STORAGE? PRESS Y FOR YES AND N FOR NO AND PRESS ENTER");
                    string uploadBlobPromptKey = Console.ReadLine();

                    if (uploadBlobPromptKey.ToUpper() == "Y")
                    {
                       ZipperUploader clientLauncherUploader = new ZipperUploader(new BlobStorageManager(ConfigurationSettings.AppSettings["DeveloperCommonAzureStorage"]));

                       clientInstallerZipDetails.ZipLocation =  clientLauncherUploader.uploadToStorage(clientInstallerZipDetails);
                       Console.WriteLine("CLIENT ZIP UPLOADED : " + clientInstallerZipDetails.ZipLocation);

                       launcherZipDetails.ZipLocation =  clientLauncherUploader.uploadToStorage(launcherZipDetails);
                       Console.WriteLine("LAUNCHER ZIP UPLOADED :" + launcherZipDetails.ZipLocation);

                       clientLauncherUploader.auditUploadedZipFiles(clientInstallerZipDetails,launcherZipDetails);
                       Console.WriteLine("SUCCESFULLY WRITTEN TO UPDATEMETADATA TABLE");

                    }

                    Console.WriteLine("==================COMPLETED======================");

                }
                else
                {
                    Console.WriteLine("PRODUCT IS NOT EQUAL TO INSTALLED VERSION");
                }

            }
            catch (VP2BinaryZipperException e)
            {
                Console.WriteLine("COULD NOT COMPRESS GENERATE ZIP FILES : " + e.Message);
            }
            catch (VP2UploaderException e)
            {
                Console.WriteLine("FAILED TO UPLOAD TO COMPLETE BLOB UPLOAD : " + e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine("UNKONWN EXCEPTION OCCURED, DO NOT KNOW HOW TO FIX THIS : " + e.Message);
            }
        }