CreateFileInfo() public method

Creates the file info.
public CreateFileInfo ( string path ) : IFileInfo
path string For this path.
return IFileInfo
コード例 #1
0
        public void OneFileIsCopiedAFewTimes([Values(true, false)]bool contentChanges, [Values(1,2,5,10)]int times) {
            this.ContentChangesActive = contentChanges;
            FileSystemInfoFactory fsFactory = new FileSystemInfoFactory();
            var fileNames = new List<string>();
            string fileName = "file";
            string content = "content";
            this.remoteRootDir.CreateDocument(fileName + ".bin", content);
            this.InitializeAndRunRepo();

            var file = this.localRootDir.GetFiles().First();
            fileNames.Add(file.FullName);
            var fileInfo = fsFactory.CreateFileInfo(file.FullName);
            Guid uuid = (Guid)fileInfo.Uuid;
            for (int i = 0; i < times; i++) {
                var fileCopy = fsFactory.CreateFileInfo(Path.Combine(this.localRootDir.FullName, string.Format("{0}{1}.bin", fileName, i)));
                file.CopyTo(fileCopy.FullName);
                Thread.Sleep(50);
                fileCopy.Refresh();
                fileCopy.Uuid = uuid;
                fileNames.Add(fileCopy.FullName);
            }

            Thread.Sleep(500);

            this.AddStartNextSyncEvent(forceCrawl: true);
            this.repo.Run();

            Assert.That(this.localRootDir.GetFiles().Length, Is.EqualTo(fileNames.Count));
            foreach (var localFile in this.localRootDir.GetFiles()) {
                Assert.That(fileNames.Contains(localFile.FullName));
                var syncedFileInfo = fsFactory.CreateFileInfo(localFile.FullName);
                Assert.That(syncedFileInfo.Length, Is.EqualTo(content.Length));
                if (localFile.FullName.Equals(file.FullName)) {
                    Assert.That(syncedFileInfo.Uuid, Is.EqualTo(uuid));
                } else {
                    Assert.That(syncedFileInfo.Uuid, Is.Not.Null);
                    Assert.That(syncedFileInfo.Uuid, Is.Not.EqualTo(uuid));
                }
            }

            Assert.That(this.repo.NumberOfChanges, Is.EqualTo(0));
        }
コード例 #2
0
        public void OneFileIsCopiedAndTheCopyIsRemoved([Values(true, false)]bool contentChanges) {
            this.ContentChangesActive = contentChanges;
            FileSystemInfoFactory fsFactory = new FileSystemInfoFactory();
            var fileNames = new List<string>();
            string fileName = "file";
            string content = "content";
            this.remoteRootDir.CreateDocument(fileName + ".bin", content);
            this.InitializeAndRunRepo();

            var file = this.localRootDir.GetFiles().First();
            fileNames.Add(file.FullName);
            var fileInfo = fsFactory.CreateFileInfo(file.FullName);
            Guid uuid = (Guid)fileInfo.Uuid;
            var fileCopy = fsFactory.CreateFileInfo(Path.Combine(this.localRootDir.FullName, fileName + " - copy.bin"));
            file.CopyTo(fileCopy.FullName);
            fileCopy.Refresh();
            fileCopy.Uuid = uuid;
            fileCopy.Delete();
            Thread.Sleep(500);

            this.repo.SingleStepQueue.SwallowExceptions = true;
            this.AddStartNextSyncEvent();
            this.repo.Run();

            Assert.That(this.localRootDir.GetFiles().Length, Is.EqualTo(1));
            var child = this.localRootDir.GetFiles().First();
            Assert.That(child.Length, Is.EqualTo(content.Length));
            Assert.That(child.Name, Is.EqualTo(fileName + ".bin"));
        }