Пример #1
0
        public void WriteManyFiles()
        {
            fileSaver.storagePath = "example_output";
            fileSaver.SetUp();

            // generate a large dictionary
            var dict = new Dictionary <string, object>();

            var    largeArray  = new string[100];
            string largeString = new string('*', 50000);

            // write lots and lots of JSON files
            int n = 100;

            string[] fpaths = new string[n];
            for (int i = 0; i < n; i++)
            {
                string fileName = string.Format("{0}", i);
                Debug.LogFormat("Queueing {0}", fileName);
                string fpath = fileSaver.HandleText(largeString, experiment, ppid, sessionNum, fileName, UXFDataType.OtherSessionData);
                fpaths[i] = fpath;
            }

            Debug.Log("###########################################");
            Debug.Log("############## CLEANING UP ################");
            Debug.Log("###########################################");
            fileSaver.CleanUp();

            Assert.Throws <System.InvalidOperationException>(() => {
                fileSaver.HandleText(largeString, experiment, ppid, sessionNum, "0", UXFDataType.OtherSessionData);
            });

            // cleanup files
            foreach (var fpath in fpaths)
            {
                System.IO.File.Delete(Path.Combine(fileSaver.storagePath, fpath));
            }
        }
Пример #2
0
        public void WriteManyFiles()
        {
            fileSaver.SetUp();

            // generate a large dictionary
            var dict = new Dictionary <string, object>();

            var largeArray = new int[10000];

            for (int i = 0; i < largeArray.Length; i++)
            {
                largeArray[i] = i;
            }

            dict["large_array"] = largeArray;

            // write lots and lots of JSON files
            int n = 100;

            string[] fpaths = new string[n];
            for (int i = 0; i < n; i++)
            {
                string fileName = string.Format("{0:000}", i);
                Debug.LogFormat("Queueing {0}", fileName);
                string fpath = fileSaver.HandleJSONSerializableObject(dict, experiment, ppid, sessionNum, fileName, UXFDataType.OtherSessionData);
                fpaths[i] = fpath;
            }

            fileSaver.CleanUp();

            // cleanup files
            foreach (var fpath in fpaths)
            {
                System.IO.File.Delete(fpath);
            }
        }