public void Test_Refresh() { PollingInterval.Interval = new TimeSpan(0, 0, 0); using (TempPolicyFolder folder = new TempPolicyFolder(Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\Policies\p5default.runtimepolicy"))) { string filename = folder.Files[0]; LocalPolicySetCache cache = new LocalPolicySetCache(filename); Assert.AreEqual(1, cache.PolicySetVersions.Count, "The policy set only has one version in it (or did at the time of writing this test)"); Assert.AreEqual(CacheValidState.Current, cache.ValidState, "We haven't done anything to the file yet so it should be up to date."); System.Threading.Thread.Sleep(100); DateTime newTime = DateTime.Now.ToUniversalTime(); File.SetLastWriteTimeUtc(filename, newTime); Assert.AreEqual(CacheValidState.OutOfDate, cache.ValidState, "We deleted the policy file so it should no longer exist on disk."); cache.Refresh(); Assert.AreEqual(CacheValidState.Current, cache.ValidState, "The policy should now be reloaded."); Assert.AreEqual(1, cache.PolicySetVersions.Count, "The policy set failed to reload on the refresh!"); Assert.AreEqual(newTime, cache.TimeStamp, "Check no blatant cheating is going on behind the scenes"); } PollingInterval.Interval = new TimeSpan(0, 0, 10); }