private void SpreadsheetTests(Action <ExcelWorksheetData> afterSetFolder)
        {
            var  worksheet         = new ExcelWorksheetData(TestContext);
            bool checkCacheChanged = worksheet.ColumnExists("CacheChanged");

            for (int i = 1; i <= 2; ++i)
            {
                string nameColumn         = String.Format("File{0}", i);
                string lastModifiedColumn = String.Format("Time{0}", i);

                if (!worksheet.ColumnExists(nameColumn))
                {
                    continue;
                }

                var name = worksheet.String(nameColumn);
                var time = worksheet.ColumnExists(lastModifiedColumn) ? worksheet.DateTime(lastModifiedColumn) : new DateTime(2999, 12, 31);
                if (name != null)
                {
                    _Files.Add(new TestFileInfo(name, time));
                }
            }
            _Provider.Setup(p => p.GetFilesInFolder(It.IsAny <string>())).Returns(_Files);

            var folder = worksheet.String("Folder");

            if (folder != null)
            {
                _DirectoryCache.Folder = folder;
            }

            if (worksheet.ColumnExists("LastModified"))
            {
                var fileInfo = worksheet.String("LastModified") == null ? null : new TestFileInfo(worksheet.String("FileName"), worksheet.DateTime("LastModified"));
                _Provider.Setup(p => p.GetFileInfo(worksheet.EString("FileName"))).Returns(fileInfo);
            }

            if (checkCacheChanged)
            {
                _DirectoryCache.CacheChanged += _CacheChangedEvent.Handler;
            }
            if (afterSetFolder != null)
            {
                afterSetFolder(worksheet);
            }

            Assert.AreEqual(folder, _DirectoryCache.Folder);
            Assert.AreEqual(worksheet.Bool("Exists"), _DirectoryCache.FileExists(worksheet.EString("SearchFor")));

            if (checkCacheChanged)
            {
                Assert.AreEqual(worksheet.Bool("CacheChanged") ? 1 : 0, _CacheChangedEvent.CallCount);
            }
        }
        private void SpreadsheetTests(Action<ExcelWorksheetData> afterSetFolder)
        {
            var worksheet = new ExcelWorksheetData(TestContext);
            bool checkCacheChanged = worksheet.ColumnExists("CacheChanged");

            for(int i = 1;i <= 2;++i) {
                string nameColumn = String.Format("File{0}", i);
                string lastModifiedColumn = String.Format("Time{0}", i);

                if(!worksheet.ColumnExists(nameColumn)) continue;

                var name = worksheet.String(nameColumn);
                var time = worksheet.ColumnExists(lastModifiedColumn) ? worksheet.DateTime(lastModifiedColumn) : new DateTime(2999, 12, 31);
                if(name != null) _Files.Add(new TestFileInfo(name, time));
            }
            _Provider.Setup(p => p.GetFilesInFolder(It.IsAny<string>())).Returns(_Files);

            var folder = worksheet.String("Folder");
            if(folder != null) _DirectoryCache.Folder = folder;

            if(worksheet.ColumnExists("LastModified")) {
                var fileInfo = worksheet.String("LastModified") == null ? null : new TestFileInfo(worksheet.String("FileName"), worksheet.DateTime("LastModified"));
                _Provider.Setup(p => p.GetFileInfo(worksheet.EString("FileName"))).Returns(fileInfo);
            }

            if(checkCacheChanged) _DirectoryCache.CacheChanged += _CacheChangedEvent.Handler;
            if(afterSetFolder != null) afterSetFolder(worksheet);

            Assert.AreEqual(folder, _DirectoryCache.Folder);
            Assert.AreEqual(worksheet.Bool("Exists"), _DirectoryCache.FileExists(worksheet.EString("SearchFor")));

            if(checkCacheChanged) Assert.AreEqual(worksheet.Bool("CacheChanged") ? 1 : 0, _CacheChangedEvent.CallCount);
        }
Example #3
0
        private void SpreadsheetTests(Action <ExcelWorksheetData> afterSetFolder)
        {
            var  worksheet         = new ExcelWorksheetData(TestContext);
            bool checkCacheChanged = worksheet.ColumnExists("CacheChanged");

            for (int i = 1; i <= 2; ++i)
            {
                string nameColumn         = String.Format("File{0}", i);
                string lastModifiedColumn = String.Format("Time{0}", i);

                if (!worksheet.ColumnExists(nameColumn))
                {
                    continue;
                }

                var name = worksheet.String(nameColumn);
                var time = worksheet.ColumnExists(lastModifiedColumn) ? worksheet.DateTime(lastModifiedColumn) : new DateTime(2999, 12, 31);
                if (name != null)
                {
                    AddToFiles(name, time);
                }
            }

            var folder = worksheet.String("Folder");

            if (folder != null)
            {
                AddToFolders(folder);
                _DirectoryCache.Folder = folder;
            }

            if (worksheet.ColumnExists("CacheSubFolders"))
            {
                _DirectoryCache.CacheSubFolders = worksheet.Bool("CacheSubFolders");
            }

            if (worksheet.ColumnExists("LastModified"))
            {
                if (worksheet.String("LastModified") != null)
                {
                    AddToFiles(worksheet.String("FileName"), worksheet.DateTime("LastModified"));
                }
            }

            if (checkCacheChanged)
            {
                _DirectoryCache.CacheChanged += _CacheChangedEvent.Handler;
            }
            if (afterSetFolder != null)
            {
                afterSetFolder(worksheet);
            }

            Assert.AreEqual(folder, _DirectoryCache.Folder);
            var result = _DirectoryCache.GetFullPath(worksheet.EString("SearchFor"));

            Assert.AreEqual(worksheet.EString("Result"), result, true);

            if (checkCacheChanged)
            {
                Assert.AreEqual(worksheet.Bool("CacheChanged") ? 1 : 0, _CacheChangedEvent.CallCount);
            }
        }