示例#1
0
        /// <summary>
        /// Retrieves a cached TestList from a file
        /// </summary>
        /// <returns>The test list if successfully loaded, otherwise null</returns>
        public async Task<TestList> RetrieveCached(string ID)
        {
            if (SampleData.DEMO)
            {
                return JsonConvert.DeserializeObject<TestList>(SampleData.cached_tests);
            }
            else
            {
                var toreturn = new TestList();
                try
                {
                    var localFolder = ApplicationData.Current.LocalFolder;
                    StorageFile sampleFile = await localFolder.GetFileAsync(ID + TESTLISTFILENAME);

                    var loadeddata = await FileIO.ReadTextAsync(sampleFile);
                    if (loadeddata != null && loadeddata != "")
                    {
                        toreturn = JsonConvert.DeserializeObject<TestList>(loadeddata);
                    }
                    return toreturn;
                }
                catch (Exception e)
                {
                    return null;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Caches a list of test files
        /// </summary>
        /// <param name="testlist">The tests to cache</param>
        public async void Cache(TestList testlist, string ID)
        {
            var localFolder = ApplicationData.Current.LocalFolder;
            var sampleFile = await localFolder.CreateFileAsync(ID + TESTLISTFILENAME, CreationCollisionOption.ReplaceExisting);

            var serialized = await JsonConvert.SerializeObjectAsync(testlist);
            await FileIO.WriteTextAsync(sampleFile, serialized);
        }
示例#3
0
        /// <summary>
        /// Loads a cached test suite if possible, otherwise does nothing.
        /// </summary>
        private async Task<bool> AttemptLoadCachedTests(string ID)
        {
            nonrecursivetestlist = await new TestCrawler().RunCachedIfPossible(ID);
            if(nonrecursivetestlist == null)
            {
                return false;
            }

            LoadTestsButtonBacking.Visibility = Visibility.Collapsed;
            CoverageData.Visibility = Visibility.Visible;
            return true;
        }
示例#4
0
        /// <summary>
        /// Opens a folder and recursively creates a TestList from it
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static async Task<TestList> Scan(StorageFolder folder, string path)
        {
            var toreturn = new TestList();
            toreturn.Tests = new List<Test>();
            toreturn.FolderName = folder.Name;

            path += "/" + toreturn.FolderName;

            foreach (var f in await folder.GetFilesAsync())
            {
                if (f.Name.EndsWith(".py"))
                {
                    toreturn.Tests.AddRange(await TestCrawler.GetTestsFromFile(f, path));
                }
            }

            foreach (var f in await folder.GetFoldersAsync())
            {
                toreturn.Tests.AddRange((await Scan(f, path)).Tests);
            }

            return toreturn;
        }
示例#5
0
        /// <summary>
        /// Allows loading a new test suite from the file picker
        /// </summary>
        private async void LoadTestListFromDisk(string ID)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();
            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.FileTypeFilter.Add("*");

            StorageFolder testfolder = await picker.PickSingleFolderAsync();
            
            if (testfolder != null)
            {
                var testcrawler = new TestCrawler();
                nonrecursivetestlist = await testcrawler.LoadFromFolder(testfolder, ID);

                TestsList.ItemsSource = nonrecursivetestlist.Tests;
                LoadTestsButtonBacking.Visibility = Visibility.Collapsed;
            }
        }