コード例 #1
0
 public async void TestImport_RepositoryConsidered(string contents, string[] paths, bool[] results)
 {
     _importerAsync = new FakeFileInfoListImporterAsyncWithRepository(contents);
     ImportedFileInfo[] validFileInfos = paths.Select(x =>
         new ImportedFileInfo
         {
             FilePath = x,
             FileType = "Test"
         }).ToArray();
     await Task.WhenAll(Task.Run(() => _importerAsync.Import(validFileInfos)), Task.Delay(500));
     string info = "";
     for (int i = 0; i < paths.Length; i++)
     {
         ImportedFileInfo fileInfo = validFileInfos.ElementAt(i);
         Assert.AreEqual(fileInfo.FilePath, paths[i]);
         Assert.AreEqual(fileInfo.CurrentState, "已读取");
         if (results[i])
         {
             Assert.AreEqual(fileInfo.Result, "导入成功");
             info += "\n" + fileInfo.FilePath + "完成导入数量:" + contents.Length;
         }
         else
         {
             Assert.AreEqual(fileInfo.Result, "无需导入");
             info += "\n日期:" + fileInfo.FilePath.RetrieveFileNameBody().GetDateExtend().ToShortDateString() 
                 + "的统计记录已导入!";
         }
     }
     Assert.AreEqual(_importerAsync.Result, info);
 }
コード例 #2
0
        public async void TestImport_RepositoryConsidered(string contents, string[] paths, bool[] results)
        {
            _importerAsync = new FakeFileInfoListImporterAsyncWithRepository(contents);
            ImportedFileInfo[] validFileInfos = paths.Select(x =>
                                                             new ImportedFileInfo
            {
                FilePath = x,
                FileType = "Test"
            }).ToArray();
            await Task.WhenAll(Task.Run(() => _importerAsync.Import(validFileInfos)), Task.Delay(500));

            string info = "";

            for (int i = 0; i < paths.Length; i++)
            {
                ImportedFileInfo fileInfo = validFileInfos.ElementAt(i);
                Assert.AreEqual(fileInfo.FilePath, paths[i]);
                Assert.AreEqual(fileInfo.CurrentState, "已读取");
                if (results[i])
                {
                    Assert.AreEqual(fileInfo.Result, "导入成功");
                    info += "\n" + fileInfo.FilePath + "完成导入数量:" + contents.Length;
                }
                else
                {
                    Assert.AreEqual(fileInfo.Result, "无需导入");
                    info += "\n日期:" + fileInfo.FilePath.RetrieveFileNameBody().GetDateExtend().ToShortDateString()
                            + "的统计记录已导入!";
                }
            }
            Assert.AreEqual(_importerAsync.Result, info);
        }
コード例 #3
0
        public async void TestImport(string contents, string[] paths, string info)
        {
            _importerAsync = new FakeFileInfoListImporterAsync(contents);
            ImportedFileInfo[] validFileInfos = paths.Select(x =>
                new ImportedFileInfo
                {
                    FilePath = x,
                    FileType = "Test"
                }).ToArray();

            await Task.WhenAll(Task.Run(() =>_importerAsync.Import(validFileInfos)), Task.Delay(300));
            
            Assert.AreEqual(_importerAsync.Result, info);
            for (int i = 0; i < paths.Length; i++)
            {
                ImportedFileInfo fileInfo = validFileInfos.ElementAt(i);
                Assert.AreEqual(fileInfo.FilePath,paths[i]);
                Assert.AreEqual(fileInfo.CurrentState, "已读取");
                Assert.AreEqual(fileInfo.Result, "导入成功");
            }
        }
コード例 #4
0
        public async void TestImport(string contents, string[] paths, string info)
        {
            _importerAsync = new FakeFileInfoListImporterAsync(contents);
            ImportedFileInfo[] validFileInfos = paths.Select(x =>
                                                             new ImportedFileInfo
            {
                FilePath = x,
                FileType = "Test"
            }).ToArray();

            await Task.WhenAll(Task.Run(() => _importerAsync.Import(validFileInfos)), Task.Delay(300));

            Assert.AreEqual(_importerAsync.Result, info);
            for (int i = 0; i < paths.Length; i++)
            {
                ImportedFileInfo fileInfo = validFileInfos.ElementAt(i);
                Assert.AreEqual(fileInfo.FilePath, paths[i]);
                Assert.AreEqual(fileInfo.CurrentState, "已读取");
                Assert.AreEqual(fileInfo.Result, "导入成功");
            }
        }