示例#1
0
        private static async Task RunCheckFileTimeTest(ADLSAdapter adapter)
        {
            DateTimeOffset?offset1 = await adapter.ComputeLastModifiedTimeAsync("/FileTimeTest/CheckFileTime.txt");

            DateTimeOffset?offset2 = await adapter.ComputeLastModifiedTimeAsync("FileTimeTest/CheckFileTime.txt");

            Assert.IsTrue(offset1.HasValue);
            Assert.IsTrue(offset2.HasValue);
            Assert.IsTrue(offset1.Value == offset2.Value);
            Assert.IsTrue(offset1.Value < DateTimeOffset.Now);
        }
示例#2
0
        private static async Task RunFileEnumTest(ADLSAdapter adapter)
        {
            using (adapter.CreateFileQueryCacheContext())
            {
                List <string> files1 = await adapter.FetchAllFilesAsync("/FileEnumTest/");

                List <string> files2 = await adapter.FetchAllFilesAsync("/FileEnumTest");

                List <string> files3 = await adapter.FetchAllFilesAsync("FileEnumTest/");

                List <string> files4 = await adapter.FetchAllFilesAsync("FileEnumTest");

                // expect 100 files to be enumerated
                Assert.IsTrue(files1.Count == 100 && files2.Count == 100 && files3.Count == 100 && files4.Count == 100);

                // these calls should be fast due to cache
                var watch = Stopwatch.StartNew();
                for (int i = 0; i < files1.Count; i++)
                {
                    Assert.IsTrue(files1[i] == files2[i] && files1[i] == files3[i] && files1[i] == files4[i]);
                    await adapter.ComputeLastModifiedTimeAsync(files1[i]);
                }
                watch.Stop();

                Assert.Performance(10, watch.ElapsedMilliseconds, "Cached file modified times");
            }
        }