Example #1
0
        public void NotDisposingDirectorySourceKeepsSourceFilesOpen()
        {
            var directoryInfo = new DirectoryInfo(Path.Combine(AssemblyLocation.FullName, "folder-feed"));

            try
            {
                var gtfsDirectorySource = new GTFSDirectorySource(directoryInfo);
                var reader = new GTFSReader <GTFSFeed>();
                reader.Read(gtfsDirectorySource);
            }
            catch (GTFSExceptionBase)
            {
                // ignore our exceptions
            }

            var agencyFile = Path.Combine(directoryInfo.FullName, "agency.txt");

            Assert.Throws <IOException>(
                () =>
            {
                using (File.OpenWrite(agencyFile))
                {
                    // do nothing
                }
            },
                "The process cannot access the file '{0}' because it is being used by another process.",
                agencyFile);
        }
Example #2
0
        public void DisposingDirectorySourceClosesSourceFiles()
        {
            var directoryInfo = new DirectoryInfo(Path.Combine(AssemblyLocation.FullName, "folder-feed"));

            try
            {
                using (var gtfsDirectorySource = new GTFSDirectorySource(directoryInfo))
                {
                    var reader = new GTFSReader <GTFSFeed>();
                    reader.Read(gtfsDirectorySource);
                }
            }
            catch (GTFSExceptionBase)
            {
                // ignore our exceptions
            }

            var agencyFile = Path.Combine(directoryInfo.FullName, "agency.txt");

            using (File.OpenWrite(agencyFile))
            {
                // do nothing
            }
        }