After following the steps, statement completion will also work for Python projects installed in a virtualenv.
We have just installed Sublime Package Control - A full-featured package manager that helps discovering, installing, updating and removing packages for Sublime Text 2. It features an automatic updater and supports GitHub, BitBucket and a full channel/repository system.
Configure Statement Completion
Press ctrl + shift + p (Windows, Linux) or cmd + shift + p (OS X).
Type Install Package and select it.
The Install Package command shows a list of all available packages that are available for install. This will include all of the packages from the [default channel](http://wbond.net/sublime_packages/community), plus any from repositories you have added.
Select SublimeCodeIntel from the list of packages.
Configure Statement Completion for Python projects in virtualenv
You may skip this if you are not using virtualenv.
Create a .codeintel directory at the root of the project
Create a config file (without any extension) inside the newly created directory.
Note that VirtualEnvName is the name of the virtualenv were the files of the project are located.
The project itself is in ~/Documents/Projects/VirtualEnvName/ProjectName
To install AutoFixture with xUnit.net data theories, run the following command in the Package Manager Console:
In the test method below we would like to use xUnit.net data theories to provide:
Auto-generated data specimens for d, s, i, a.
Auto-generated data specimens for _, s, i, a, and inline values for d.
Auto-generated data specimens for _, _, i, a, and inline values for d, s.
That fact that argument i is an interface and argument a is an abstract class prevents us from using [InlineData], [AutoData], or [InlineAutoData] attributes.
AutoFixture allows us to easily define custom DataAttribute derived types:
By deriving from AutoDataAttribute and passing to the base constructor a customization that enables auto mocking with Moq, Rhino Mocks, FakeItEasy, or NSubstitute.
By deriving from CompositeDataAttribute and passing to the base constructor an array of DataAttribute derived type instances, e.g. an instance of InlineDataAttribute and an instance of AutoDataAttribute derived type.
Auto Mocking using Moq
To install AutoFixture with Auto Mocking using Moq, run the following command in the Package Manager Console:
We decorate the test method with AutoMoqData and InlineAutoMoqData attributes:
xUnit.netextensions support data-driven tests called Theories. Such tests are similar to regular xUnit.net tests but instead of being decorated with [Fact] they are decorated with [Theory].
Below is a data-driven test with the data coming a Microsoft Excel (.xls) spreadsheet.
Also, a data-driven test with the data coming from a type implementing the IEnumerable<object>.
In the above samples, [ExcelData] and [ClassData] are attributes representing a data source for a data-driven test.
Using data from multiple attributes
Below is a data-driven test with the data coming from a type implementing the IEnumerable<object> combined with the data coming from an .xls spreadsheet.
Creating a composite attribute
The [ClassExcelData] from the previous example is a composite of two xUnit.net’s data attributes [ClassData] and [ExcelData].
All we have to do is create a type deriving from CompositeDataAttribute, passing in its base constructor an array of the data attributes we would like to compose.
The description for the CompositeDataAttribute algorithm can be found here.
When defining a composite data attribute, it is acceptable for the first attribute to provide some (or all) data for the parameters of the test method. However, subsequent data attributes must be able to provide the data for the exact position where the previous attribute stopped.
This post is the result of a very good suggestion) in the comments section of the previous post.
The WindsorDependencyScope from the previous post has been modified to use the Scoped lifetime available in Castle Windsor 3.
The BeginScope is an extension method for the IWindsorContainer type. It returns by default an instance of a CallContextLifetimeScope type. It uses the Call Context so it can be associated with thread pool threads and manually created threads within a single AppDomain (it does not use the Logical Call Context).
Both interfaces contain method(s) accepting, among others, an HttpRequestMessage. The trick here is to use the HttpRequestMessage’s extension method GetDependencyScope for resolving controllers (instead of using a DI Container directly).
Internally, the GetDependencyScope method uses the DependencyResolver (registered in the GlobalConfiguration instance) calling it’s BeginScope method which creates a new resolution scope. Objects that are resolved in that scope are tracked internally. Once the scope is disposed, those objects are released (using the container’s Release method).
Below is an implementation of the IDependencyScope interface:
Having a custom implementation of the IDependencyScope interface, we can now move on with the implementation of the IDependencyResolver interface. The recommendation (from the source code) is to return a new instance of IDependencyScope every time the BeginScope method is called.
An implementation of the IDependencyResolver interface for Castle Windsor could be similar to the one below:
As we can see, the BeginScope method returns a new instance of IDependencyScope which can resolve and release objects that belong to that scope.
Moving next, when upgrading from Beta to RC there might be another thing to consider. Since the IHttpControllerFactory interface has now been removed, implementations of that interface were using the controllerName in order to resolve component instances from the DI Containers. As a result, controllers were registered in the DI Containers using names for each registration.
A DefaultHttpControllerSelector derived type could be similar to the one below:
Make sure to register the above type in Castle Windsor otherwise the framework will pick it's default implementation.
All the above information is the result of browsing the source code on CodePlex. If any articles or blog posts are released (by the ASP.NET team or individuals) I might create a new post with updates, if necessary.