Exemplo n.º 1
0
 public override IList<ErrorLog> List()
 {
     try
     {
         using(var zip = new ZipFile(Path))
             return new List<ErrorLog>(zip.Select(ErrorLog).OrderByDescending(e => e.Time));
     }
     catch(Exception)
     {
         return new List<ErrorLog>();
     }
 }
Exemplo n.º 2
0
        public void BytesToZipTest()
        {
            var tempZip = Path.Combine(_confSection.Settings.Paths.Surveys, _surveyDir + ".zip");

            using (var zipFileStream = new FileStream(_pathToZipForInstall, FileMode.Open, FileAccess.Read))
                _packageManager.BytesToZip(ReadStreamToEnd(zipFileStream), tempZip);

            var filesInZipFromBytes = new List<string>();
            using (var zip = new ZipFile(tempZip) { UseUnicodeAsNecessary = true })
                filesInZipFromBytes.AddRange(zip.Select(file => file.FileName));

            CollectionAssert.AreEquivalent(_filesInInstallZip, filesInZipFromBytes);
        }
Exemplo n.º 3
0
        private static void AssertZipsEqual(ZipFile expected, ZipFile actual)
        {
            actual.Count.ShouldEqual(expected.Count, "zip files contain different counts");

                var allFiles = actual.Select(s => s.FileName).ToArray();

            foreach (var expectedFile in expected)
            {
                string firstOrDefault = allFiles.Where(w => w.Equals(expectedFile.FileName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                firstOrDefault.ShouldNotBeNull("Could not find file {0} in files \n{1}".FormatWith(
                    expectedFile.FileName,
                    string.Join(Environment.NewLine, allFiles)));
                //allFiles.Contains(expectedFile.FileName).ShouldBeTrue();
            }
            //for (int i = 0; i < expected.Count; i++)
            //{
            //    var expectedFile = expected[i];
            //    var actualFile = actual[i];
            //
            //    actualFile.FileName.ShouldEqual(expectedFile.FileName);
            //    //actualFile.ToByteArray().ShouldEqual(expectedFile.ToByteArray(), "File [{0}] bytes not same.".FormatWith(actualFile.FileName));
            //}
        }
Exemplo n.º 4
0
        public void CreateTestEnvironment()
        {
            _surveyDir = "TestSurvey" + TestUtils.GetPostfix();
            _confSection = DeployerConfigurationSection.Instance;
            _packageManager = new PackageManager();

            var pathToZipsForTests = _confSection.Settings.Paths.Uploads;
            _pathToFolderForDeploy = _confSection.Settings.Paths.Surveys;
            _pathToZipForInstall = Path.Combine(pathToZipsForTests, "TestSurvey.zip");
            _pathToZipForUpdate = Path.Combine(pathToZipsForTests, "TestSurveyUpd.zip");
            _pathToZipForUpdateOnlyBin = Path.Combine(pathToZipsForTests, "TestSurveyUpdOnlyBin.zip");
            _pathToZipForUpdateOnlyAppData = Path.Combine(pathToZipsForTests, "TestSurveyUpdOnlyAppData.zip");

            _filesInInstallZip = new List<string>();
            using (var zip = new ZipFile(_pathToZipForInstall) { UseUnicodeAsNecessary = true })
                _filesInInstallZip.AddRange(zip.Select(file => file.FileName));

            Directory.CreateDirectory(_pathToFolderForDeploy);
        }
Exemplo n.º 5
0
        public void FolderToZipTest()
        {
            var tempZip = Path.Combine(_confSection.Settings.Paths.Surveys, _surveyDir + ".zip");
            var pathToSurvey = Path.Combine(_confSection.Settings.Paths.Surveys, _surveyDir);

            _packageManager.UnpackZipSilently(_pathToZipForInstall, pathToSurvey);
            _packageManager.FolderToZip(pathToSurvey, tempZip);

            var filesInNewZip = new List<string>();
            using (var zip = new ZipFile(tempZip) { UseUnicodeAsNecessary = true })
                filesInNewZip.AddRange(zip.Select(file => file.FileName));

            CollectionAssert.AreEquivalent(_filesInInstallZip, filesInNewZip);
        }