public void storageDoesNotAccess()
 {
     StorageManagerMock storageDoesNotExist = new StorageManagerMock();
     storageDoesNotExist.setStorageExists(false);
     ZipperUploader mockUploader = new ZipperUploader(storageDoesNotExist);
     mockUploader.uploadToStorage(new ZipDetails()
     {
         ZipName = "test",
         ZipLocation = "testBlob"
     });
 }
 public void storageCannotAccess()
 {
     StorageManagerMock storageCannotAccess = new StorageManagerMock();
     storageCannotAccess.setStorageAccess(false);
     ZipperUploader mockUploader = new ZipperUploader(storageCannotAccess);
     mockUploader.uploadToStorage(new ZipDetails()
     {
         ZipName = "test",
         ZipLocation = "testBlob"
     });
 }
 public void uploadToBlobStorage()
 {
     StorageManagerMock uploadToBlob = new StorageManagerMock();
     uploadToBlob.setStorageAccess(true);
     ZipperUploader mockUploader = new ZipperUploader(uploadToBlob);
     string uploadedID = mockUploader.uploadToStorage(new ZipDetails()
     {
         ZipName = "test",
         ZipLocation = "testBlob"
     });
     Assert.AreEqual(uploadedID, "test");
 }
 public void testStorageExists()
 {
     StorageManagerMock storageMetadataAlreadyExists = new StorageManagerMock();
     storageMetadataAlreadyExists.addProductVersion("4.3.2.111");
     ZipperUploader uploader = new ZipperUploader(storageMetadataAlreadyExists);
     uploader.auditUploadedZipFiles(new ZipDetails()
     {
         ZipName = "ClientBinaries4.3.2.111.zip",
         ZipLocation = "name"
     },new ZipDetails()
     {
         ZipName = "name",ZipLocation = "name"
     } );
 }
 public void testStorageMetaDataUploadProblem()
 {
     StorageManagerMock storageMetadataAlreadyExists = new StorageManagerMock();
     storageMetadataAlreadyExists.setExpectedException(true);
     ZipperUploader uploader = new ZipperUploader(storageMetadataAlreadyExists);
     uploader.auditUploadedZipFiles(new ZipDetails()
     {
         ZipName = "ClientBinaries4.3.2.111.zip",
         ZipLocation = "name"
     }, new ZipDetails()
     {
         ZipName = "name",
         ZipLocation = "name"
     });
 }
        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);
            }
        }