﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Mocking the file system</title><description>Matt,
  
I think that Bill Simser has something like that on CodePlex as well. This approach is very common.
  
In this case, I wanted something very specific, which was why I used this approach instead of full blown adapter.
</description><link>http://ayende.com/3451/mocking-the-file-system#comment2</link><guid>http://ayende.com/3451/mocking-the-file-system#comment2</guid><pubDate>Sun, 27 Jul 2008 16:02:14 GMT</pubDate></item><item><title>Matt Campbell commented on Mocking the file system</title><description>At work, we have been working around the issue of testing things that interact with the filesystem.  Frustrated by the extreme lack of abstraction in the Framework's System.IO namespace, we decided to create our own abstraction layer called ISystemIOAdapter (which is really a cross between an Adapter pattern and a Proxy pattern, but I digress).
  
  
The implementation of SystemIOAdapter is a trivial pass-through to the System.IO methods (many of them statics, such as Directory.GetFiles).  In our case, since we're not using an IoC container, we also had to make it a Singleton with a leaky encapsulation (we needed a ResetInstance() method in order to clean up after tests where we mocked it).
  
  
This has allowed us to use Rhino Mocks to create clean interaction-based tests of things which I.E. need to iterate through a directory structure in a specific way, which do not require complicated/expensive setups of creating actual directories and files.  It's been a real help to us, since our current projects are doing a whole lot of filesystem work.
</description><link>http://ayende.com/3451/mocking-the-file-system#comment1</link><guid>http://ayende.com/3451/mocking-the-file-system#comment1</guid><pubDate>Sun, 27 Jul 2008 15:36:28 GMT</pubDate></item></channel></rss>