public void ExpiresReturnsTrueIfFileDisappears()
        {
            FileDependency dependency = new FileDependency("TestFile");

            File.Delete("TestFile");

            Assert.IsTrue(dependency.HasExpired(), "Deleted files should always be considered expired");
        }
        public void ExpiresReturnsTrueIfFileDisappears()
        {
            FileDependency dependency = new FileDependency("TestFile");

            File.Delete("TestFile");

            Assert.IsTrue(dependency.HasExpired(), "Deleted files should always be considered expired");
        }
Exemplo n.º 3
0
        public void ExpiresIfTouched()
        {
            FileDependency dependency = new FileDependency("TestFile");
            Thread.Sleep(1500);
            using (FileStream outputStream = File.OpenWrite("TestFile"))
            {
                outputStream.WriteByte(0x00);
            }

            Assert.IsTrue(dependency.HasExpired(), "File was touched, so it should be considered expired");
        }
        public void ExpiresIfTouched()
        {
            FileDependency dependency = new FileDependency("TestFile");

            Thread.Sleep(1500);
            using (FileStream outputStream = File.OpenWrite("TestFile"))
            {
                outputStream.WriteByte(0x00);
            }

            Assert.IsTrue(dependency.HasExpired(), "File was touched, so it should be considered expired");
        }
        public void NoPermissionToReadWhenCheckingExpiration()
        {
            FileDependency dependency = new FileDependency("TestFile");

            FileIOPermission denyPermission =
                new FileIOPermission(FileIOPermissionAccess.Read, Path.GetFullPath("TestFile"));

            PermissionSet permissions = new PermissionSet(PermissionState.None);
            permissions.AddPermission(denyPermission);
            permissions.Deny();

            try
            {
                dependency.HasExpired();
            }
            finally
            {
                CodeAccessPermission.RevertDeny();
            }
        }
Exemplo n.º 6
0
        public void NoPermissionToReadWhenCheckingExpiration()
        {
            FileDependency dependency = new FileDependency("TestFile");

            FileIOPermission denyPermission =
                new FileIOPermission(FileIOPermissionAccess.Read, Path.GetFullPath("TestFile"));

            PermissionSet permissions = new PermissionSet(PermissionState.None);

            permissions.AddPermission(denyPermission);
            permissions.Deny();

            try
            {
                dependency.HasExpired();
            }
            finally
            {
                CodeAccessPermission.RevertDeny();
            }
        }