public async Task CanGetArchiveFolder()
        {
            var secretRepository = vContainer.Resolve <ISecretRepository>();
            var secret           = new ArchiveFolderFinderSecret();
            var folder           = BackbendFoldersSecret.DefaultFolder;

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var archiveFolderFinder = await secretRepository.CompileCsLambdaAsync <string, string>(secret.DefaultValue);

            var archiveFolder = archiveFolderFinder(folder);

            Assert.IsTrue(archiveFolder.Length != 0);
            Assert.IsTrue(archiveFolder != folder);
            Assert.IsTrue(Directory.Exists(archiveFolder));
            Assert.AreEqual(0, Directory.GetFiles(archiveFolder).Length);
            Directory.Delete(archiveFolder);
            var otherArchiveFolder = archiveFolderFinder(folder);

            Assert.AreEqual(archiveFolder, otherArchiveFolder);
            Assert.IsTrue(Directory.Exists(archiveFolder));
        }
        public void CanGetDefaultArchiveFolderAndSecretGuid()
        {
            var secret = new ArchiveFolderFinderSecret();

            Assert.IsNotNull(secret.DefaultValue);
            Assert.IsFalse(string.IsNullOrEmpty(secret.Guid));
        }
        public async Task CanAnalyzeBackbendFolders()
        {
            var folder        = BackbendFoldersSecret.DefaultFolder;
            var archiveFolder = folder.Replace(@"\Test\", @"\TestArchive\");

            if (!Directory.Exists(archiveFolder))
            {
                Directory.CreateDirectory(archiveFolder);
            }
            var otherFolder = folder + @"Sub\";

            if (!Directory.Exists(otherFolder))
            {
                Directory.CreateDirectory(otherFolder);
            }

            var textFileName = folder + "Test.txt";

            File.WriteAllText(textFileName, textFileName);

            var archiveFileName = archiveFolder + "Test.zip";

            File.Delete(archiveFileName);

            var backbendFolders = new BackbendFolders {
                new BackbendFolder {
                    Name = folder
                },
                new BackbendFolder {
                    Name = archiveFolder
                }
            };

            var errorsAndInfos = new ErrorsAndInfos();
            await backbendFolders.ResolveAsync(vContainer.Resolve <IFolderResolver>(), errorsAndInfos);

            Assert.IsFalse(errorsAndInfos.AnyErrors(), errorsAndInfos.ErrorsToString());

            var secretRepositoryMock = new Mock <ISecretRepository>();

            secretRepositoryMock.Setup(s => s.GetAsync(It.IsAny <ISecret <BackbendFolders> >(), It.IsAny <IErrorsAndInfos>())).Returns(Task.FromResult(backbendFolders));
            secretRepositoryMock.Setup(s => s.CompileCsLambdaAsync <string, string>(It.IsAny <CsLambda>())).Returns(
                Task.FromResult <Func <string, string> >(
                    s => new Folder(s).FullName == new Folder(folder).FullName ? archiveFolder : ""
                    )
                );

            var secret = new ArchiveFolderFinderSecret();

            secretRepositoryMock.Setup(s => s.GetAsync(It.IsAny <ArchiveFolderFinderSecret>(), It.IsAny <IErrorsAndInfos>())).Returns(Task.FromResult(secret.DefaultValue));

            var sut = new BackbendFoldersAnalyser(vContainer.Resolve <IFolderResolver>(), secretRepositoryMock.Object);

            errorsAndInfos = new ErrorsAndInfos();
            var result = await sut.AnalyzeAsync(errorsAndInfos);

            var resultList = result.ToList();

            Assert.IsFalse(errorsAndInfos.Errors.Any(), string.Join("\r\n", errorsAndInfos.Errors));
            Assert.AreEqual(1, resultList.Count);

            File.WriteAllText(archiveFileName, textFileName);

            result = await sut.AnalyzeAsync(errorsAndInfos);

            resultList = result.ToList();
            Assert.IsFalse(errorsAndInfos.Errors.Any(), string.Join("\r\n", errorsAndInfos.Errors));
            Assert.AreEqual(0, resultList.Count);

            var otherTextFileName = otherFolder + "Test.txt";

            File.WriteAllText(otherTextFileName, otherTextFileName);
            File.SetLastWriteTime(otherTextFileName, DateTime.Now.AddDays(29));

            result = await sut.AnalyzeAsync(errorsAndInfos);

            resultList = result.ToList();
            Assert.IsFalse(errorsAndInfos.Errors.Any(), string.Join("\r\n", errorsAndInfos.Errors));
            Assert.AreEqual(1, resultList.Count);

            File.Delete(textFileName);
            File.Delete(archiveFileName);
            File.Delete(otherTextFileName);
            Assert.AreEqual(0, Directory.GetFiles(otherFolder).Length);
            Directory.Delete(otherFolder);
        }