Beispiel #1
0
        public void TestDetectDeletedAndOutOfDate_RemoveAndAddFile()
        {
            PollingInterval.Interval = new TimeSpan(0, 0, 0);
            using (TempPolicyFolder folder = new TempPolicyFolder(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\Policies\p5default.runtimepolicy")))
            {
                Assert.AreEqual(1, folder.Files.Length, "We have only put the p5 default policy there.");
                string policyFile = folder.Files[0];
                LocalPolicyCache lpc = new LocalPolicyCache(folder.Path, true);
                Assert.AreEqual(1, lpc.PolicySets.Count, "We have only put the p5 default policy there so the cache should only load one.");
                File.Delete(policyFile);
                Assert.AreEqual(1, lpc.PolicySets.Count, "The update should not happen yet.");
                lpc.AttemptRefresh();
                Assert.AreEqual(0, lpc.PolicySets.Count, "We killed the file, the policy set should not be there anymore.");
                File.Copy(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\Policies\p5default.runtimepolicy"), policyFile);
                lpc.AttemptRefresh();
                Assert.AreEqual(1, lpc.PolicySets.Count, "We replaced the file so this should be good again.");
            }

            PollingInterval.Interval = new TimeSpan(0, 0, 10);
        }