private DummyFixModel InitializeDummyFixModel()
        {
            var fileSystem = new DummyFileSystem();

            fileSystem.WriteAllBytes("index.html", File.ReadAllBytes(@"TestData\FixModel\index.html"));

            var fixModel = new DummyFixModel("Test dummy", fileSystem);

            var replacements = new List <ReplacementModel>();

            replacements.Add(new ReplacementModel()
            {
                Offset = 191, DeletedLength = 0, InsertedString = "\""
            });
            replacements.Add(new ReplacementModel()
            {
                Offset = 199, DeletedLength = 0, InsertedString = "\""
            });
            replacements.Add(new ReplacementModel()
            {
                Offset = 233, DeletedLength = 3, InsertedString = "img"
            });
            replacements.ForEach(rm => rm.InsertedBytes = Encoding.UTF8.GetBytes(rm.InsertedString));

            var changeModel = new FileChangeModel()
            {
                FilePath = @"C:\source\index.html"
            };

            replacements.ForEach(r => changeModel.Replacements.Add(r));
            fixModel.FileChanges.Add(changeModel);

            return(fixModel);
        }
Exemple #2
0
        public async Task Unmount_Timeout()
        {
            // Mount the file system
            DummyFileSystem dummyFileSystem = new DummyFileSystem();
            string          mountPoint      = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(mountPoint);
            IFuseMount mount = Fuse.Mount(mountPoint, dummyFileSystem);

            // Open a file and try to unmount
            FileStream openedFile = File.OpenRead(Path.Combine(mountPoint, "filename"));
            long       startTime  = Stopwatch.GetTimestamp();
            const int  timeout    = 1000;
            bool       unmounted  = await mount.UnmountAsync(timeout);

            long endTime = Stopwatch.GetTimestamp();

            // Unmounting times out.
            Assert.False(unmounted);
            Assert.True((1000 * (endTime - startTime)) / Stopwatch.Frequency >= timeout);

            // Close the file and try to unmount
            openedFile.Close();
            // Unmounting succeeds.
            unmounted = await mount.UnmountAsync();

            Assert.True(unmounted);
        }
Exemple #3
0
        public void MountFail_DisposesFileSystem_And_ThrowsFuseException()
        {
            DummyFileSystem dummyFileSystem = new DummyFileSystem();

            Assert.Throws <FuseException>(() => Fuse.Mount("/tmp/no_such_mountpoint", dummyFileSystem));
            Assert.Equal(1, dummyFileSystem.DisposeCount);
        }
Exemple #4
0
        public async Task Unmount_DisposesFileSystem()
        {
            DummyFileSystem dummyFileSystem = new DummyFileSystem();
            string          mountPoint      = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(mountPoint);

            IFuseMount mount = Fuse.Mount(mountPoint, dummyFileSystem);

            bool unmounted = await mount.UnmountAsync(1000);

            Assert.True(unmounted);

            Assert.Equal(1, dummyFileSystem.DisposeCount);
        }