Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tpluscode/nancy.boostrapper.experiments

Testing the behaviour of various Nancy bootstrappers
https://github.com/tpluscode/nancy.boostrapper.experiments

Last synced: 6 days ago
JSON representation

Testing the behaviour of various Nancy bootstrappers

Awesome Lists containing this project

README

        

# Nancy.Boostrapper.Experiments
Testing the behaviour of various Nancy bootstrappers

## Why?

I had some issues with Nancy bootstrappers, the `Registrations` class and how various DI containers consume these registrations.

In this repository I'm comparing the available bootstrappers to see how the operate in different circumstances.

In my opinion the `Registrations` class should help unify the basic container API so that publishers of libraries extending Nancy
can be sure that the behaviour will be the same regardless of the bootstrapper chosen by the consumer.

## The tests

1. [`Register(Lifetime.PerRequest)`, where `T` has dependency registered inside bootstrapper](https://github.com/tpluscode/Nancy.Boostrapper.Experiments/blob/master/Nancy.Bootstrapper.TestSubjects/Test1.cs)
2. [Mutiple calls to `Register(Lifetime.Singleton)` - injected as `IEnumerable`](https://github.com/tpluscode/Nancy.Boostrapper.Experiments/blob/master/Nancy.Bootstrapper.TestSubjects/Test2.cs)
3. [`RegisterAll(Lifetime.Singleton)` - injected as `IEnumerable`](https://github.com/tpluscode/Nancy.Boostrapper.Experiments/blob/master/Nancy.Bootstrapper.TestSubjects/Test3.cs)
4. [Mutiple calls to `Register(Lifetime.PerRequest)` - injected as `IEnumerable`](https://github.com/tpluscode/Nancy.Boostrapper.Experiments/blob/master/Nancy.Bootstrapper.TestSubjects/Test4.cs)
5. [`RegisterAll(Lifetime.PerRequest)` - injected as `IEnumerable`](https://github.com/tpluscode/Nancy.Boostrapper.Experiments/blob/master/Nancy.Bootstrapper.TestSubjects/Test5.cs)
6. [Injecting `PerRequest` component into `IRequestStartup`](https://github.com/tpluscode/Nancy.Boostrapper.Experiments/blob/master/Nancy.Bootstrapper.TestSubjects/Test6.cs)

### Test Results

| Test ------------------> | 1 | 2 | 3 | 4 | 5 | 6 |
| ---------------------------------------- |----|---------------|---------------|---------------|---------------|---------------|
| TinyIoC |:+1:|:+1: |:+1: |:+1: |:x:1|:+1: |
| TinyIoC (no auto reg) |:+1:|:x:2|:+1: |:x:2|:+1: |:+1: |
| [Autofac][Autofac] |:+1:|:+1: |:+1: |:+1: |:+1: |:+1: |
| [DryIoc][DryIoc] |:+1:|:+1: |:+1: |:+1: |:+1: |:+1: |
| [Grace][Grace]1 |:x: |:x: |:x: |:x: |:x: |:x: |
| [LightInject][LightInject]1,2 |:+1:|:x:3|:+1: |:x:3|:+1: |:+1: |
| [MEF][MEF]1 |:x: |:x: |:x: |:x: |:x: |:x: |
| [MEF2][MEF2] |:+1:|:+1: |:x:1|:+1: |:x:1|:x:2|
| [Ninject][Ninject] |:+1:|:+1: |:+1: |:+1: |:+1: |:+1: |
| [StructureMap][StructureMap] |:+1:|:+1: |:+1: |:+1: |:+1: |:+1: |
| [Unity][Unity]1 |:+1:|:x:2|:+1: |:x:2|:+1: |:+1: |
| [Windsor][Windsor]1 |:+1:|:+1: |:+1: |:+1: |:+1: |:+1: |

### Test notes

### TinyIoC

**1** - When autoregistration is enabled, PerRequest components are resolved twice. I guess they are registered in both scopes. See issue [NancyFx/Nancy#2384](https://github.com/NancyFx/Nancy/issues/2384)

**2** - TinyIoC resolves collections only if registered with `RegisterAll`/`RegisterMultiple`

### Grace

**1** - Grace package has an outdated Nancy dependency and doesn't work with latest version.

### MEF

**1** - MEF package has an outdated Nancy dependency and doesn't work with latest version.

### MEF2

**1** - this one is weird - `RegisterAll()` has no effect with MEF2

**2** - MEF2 bootstrapper doesn't do `IRequestStartup` at all

### Windsor

**1** - Windsor doesn't create a child container but uses a per-request scope. This is a problem for tests and transient registration was used instead

### LightInject

**1** - LightInject doesn't create a child container. Instead `PerScopeLifetime` must be used.

**2** - LightInject requires .NET 4.5.1

**3** - LightInject registers only one instance of a component when `Register<>()` is called multiple times

### Unity

**1** - Unity bootstrapper has a dependency on Unity >= 2.1.505 and works fine with version 3.5, but breaks with 4.0.

**2** - Unity registers only one instance of a component when `Register<>()` is called multiple times

[Autofac]: https://github.com/NancyFx/Nancy.Bootstrappers.Autofac
[DryIoc]: https://github.com/lcssk8board/Nancy.Bootstrappers.DryIoc
[Grace]: https://github.com/ipjohnson/Nancy.Bootstrappers.Grace
[MEF]: https://github.com/wasabii/Nancy.Bootstrappers.Mef
[MEF2]: https://github.com/AaronShiels/Nancy.Bootstrappers.Mef2
[Ninject]: https://github.com/NancyFx/Nancy.Bootstrappers.Ninject
[StructureMap]: https://github.com/NancyFx/Nancy.Bootstrappers.StructureMap
[Unity]: https://github.com/NancyFx/Nancy.Bootstrappers.Unity
[Windsor]: https://github.com/NancyFx/Nancy.Bootstrappers.Windsor
[LightInject]: http://seesharper.github.io/LightInject/#nancy