Exemplo n.º 1
0
        public void TestOverwriteFileInFileSystem()
        {
            var folderPath = new AnnoRDA.Folder("path");
            {
                var folderTo = new AnnoRDA.Folder("to");
                {
                    folderTo.Add(new AnnoRDA.File("file.txt")
                    {
                        ModificationDate = new DateTime(),
                    });
                }
                folderPath.Add(folderTo);
            }

            var file = new AnnoRDA.FileEntities.FileHeader()
            {
                Path                  = "path/to/file.txt",
                DataOffset            = 11111111,
                CompressedFileSize    = 36960,
                UncompressedFileSize  = 36960,
                ModificationTimestamp = 1448398881,
            };

            var loader = new ContainerFileLoader();

            AnnoRDA.FileSystem fileSystem;
            using (var context = new ContainerFileLoader.Context("dummy.rda", TestData.GetStream(), false, new PassThroughFileHeaderTransformer())) {
                fileSystem = context.FileSystem;
                fileSystem.Root.Add(folderPath);
                loader.AddFileToFileSystem(context, file, TestData.GetDummyBlockContentsSource());
            }

            Assert.FolderAndFileCountAreEqual(1, 0, fileSystem.Root);
            Assert.FolderAndFileCountAreEqual(1, 0, fileSystem.Root.Folders.First());
            Assert.FolderAndFileCountAreEqual(0, 1, fileSystem.Root.Folders.First().Folders.First());
            Assert.ContainsFile(fileSystem, new Assert.FileSpec("path", "to", "file.txt")
            {
                CompressedFileSize    = 36960,
                UncompressedFileSize  = 36960,
                ModificationTimestamp = 1448398881,
            });
        }
Exemplo n.º 2
0
        public void TestAddFileToEmptyFileSystem()
        {
            var file = new AnnoRDA.FileEntities.FileHeader()
            {
                Path                  = "path/to/file.txt",
                DataOffset            = 11111111,
                CompressedFileSize    = 36960,
                UncompressedFileSize  = 36960,
                ModificationTimestamp = 1448398881,
            };

            var loader = new ContainerFileLoader();

            AnnoRDA.FileSystem fileSystem;
            using (var context = new ContainerFileLoader.Context("dummy.rda", TestData.GetStream(), false, new PassThroughFileHeaderTransformer())) {
                loader.AddFileToFileSystem(context, file, TestData.GetDummyBlockContentsSource());
                fileSystem = context.FileSystem;
            }

            Assert.FolderAndFileCountAreEqual(1, 0, fileSystem);
            Assert.ContainsFile(fileSystem, new Assert.FileSpec("path", "to", "file.txt"));
        }