PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Extensions/src/Ncqrs.Config.Windsor.Tests/WindsorConfigurationTests.cs

http://github.com/ncqrs/ncqrs
C# | 42 lines | 34 code | 8 blank | 0 comment | 0 complexity | ee40e8b57706b1816e47a757330f4851 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0
  1. using Castle.MicroKernel.Registration;
  2. using Castle.Windsor;
  3. using FluentAssertions;
  4. using NUnit.Framework;
  5. namespace Ncqrs.Config.Windsor.Tests
  6. {
  7. [TestFixture]
  8. public class WindsorConfigurationTests
  9. {
  10. [Test]
  11. public void When_component_is_registered_it_should_be_retrievable()
  12. {
  13. var container = new WindsorContainer();
  14. container.Register(Component.For<IReplicant>().ImplementedBy<Nexus6>());
  15. var configuration = new WindsorConfiguration(container);
  16. IReplicant component;
  17. var success = configuration.TryGet(out component);
  18. success.Should().BeTrue();
  19. component.Should().NotBeNull();
  20. component.Should().BeOfType<Nexus6>();
  21. }
  22. [Test]
  23. public void When_component_is_not_registered_it_should_not_be_retrievable()
  24. {
  25. var configuration = new WindsorConfiguration(new WindsorContainer());
  26. IReplicant component;
  27. var success = configuration.TryGet(out component);
  28. success.Should().BeFalse();
  29. component.Should().BeNull();
  30. }
  31. }
  32. public interface IReplicant { }
  33. public class Nexus6 : IReplicant {}
  34. }