public void Cache()
        {
            var device = new CachedWebDiscoveryDevice { DiscoveryUri = new Uri("http://google.com") };

            // Get the cache file info
            FileInfo cacheFile = device.GetCacheFile();
            Assert.IsNotNull(cacheFile);

            // Delete the file (if it exists)
            if (cacheFile.Exists)
            {
                cacheFile.Delete();
            }

            // Check that the file does not exist anymore
            cacheFile = device.GetCacheFile();
            Assert.IsFalse(cacheFile.Exists);

            // Execute the fetch
            using (Stream stream = device.Fetch())
            {
                Assert.IsNotNull(stream);
            }

            // Check if the file was cached
            cacheFile = device.GetCacheFile();
            Assert.IsTrue(cacheFile.Exists);
            Assert.That(cacheFile.Length, Is.GreaterThan(0));

            // Remove the newly created file
            cacheFile.Delete();
        }
        public void InvalidFilenames()
        {
            var device = new CachedWebDiscoveryDevice
                             { DiscoveryUri = new Uri("http://google.com/$#@!%^&*()[]+=/\\<>:;") };

            // Check if the file name was escaped at all
            FileInfo cacheFile = device.GetCacheFile();
            Assert.That(cacheFile.Name.Contains("_"));

            // Check the result
            Assert.IsFalse(cacheFile.Name.Contains("/"));
            
            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                // Don't check this on mono, as mono automatically escapes the file name
                Assert.IsTrue(cacheFile.Name.StartsWith("http___google.com_$#@!%25^&_()[]+=_____;-"));
            }
        }