Project Description
AutoFakes makes it easier for developers to automatically build classes when testing. You'll no longer have to manually call your class-under-test's constructor, passing it individual stubs - AutoFakes handles that for you... automatically. AutoFakes is developed in C#.

For Visual Studio 11

AutoFakes uses the Visual Studio 11 Stubbing functionality and makes it easier to build your class under test. As long as the class under test's constructor takes Interface or Abstract Class parameters as dependencies, and as long as you have Fakes built for those interfaces/abstract classes (right click on your DLL reference in your test project and select "Add Fakes Assembly"), AutoFakes will find the appropriate Stub classes and pass them to the constructor for your class under test.

        public void ConnectorManagerCanGetConnectors()
            // Arrange
            // ConnectorManager has a dependency - IConnectorRepository
            var autoStub = new AutoStub<ConnectorManager>();
            var stubConnector = new StubIConnector();
            autoStub.Get<StubIConnectorRepository>().GetConnectorsString =
                filter =>
                    return new List<IConnector> {stubConnector, stubConnector};

            // Act
            IList<IConnector> result = autoStub.Target.GetConnectors("filter");

            // Assert
            Assert.AreEqual(2, result.Count);

The advantage of using this framework is that if your class under test changes, for example - adding additional dependencies, you don't have to come back to each test and add in the additional dependencies yourself - AutoFakes will do it for you behind the scenes.

Last edited Apr 29, 2012 at 1:14 AM by dseelinger, version 11