PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Extensions/src/Ncqrs.Config.Ninject.Tests/NinjectAggregateRootCreationStrategyTests.cs

http://github.com/ncqrs/ncqrs
C# | 74 lines | 57 code | 17 blank | 0 comment | 0 complexity | 7430a5a0396b5dd29285bd0d34eb164f MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using FluentAssertions;
  6. using Ncqrs.Domain;
  7. using Ncqrs.Domain.Storage;
  8. using Ncqrs.Spec;
  9. using Ninject;
  10. namespace Ncqrs.Config.Ninject.Tests
  11. {
  12. public class NinjectAggregateRootCreationStrategyTests
  13. : BaseTestFixture
  14. {
  15. private IAggregateRootCreationStrategy _creationStrategy;
  16. private FakeAggregate _aggregate;
  17. private class FakeAggregate : AggregateRoot
  18. {
  19. public bool CorrectConstructorCalled { get; private set; }
  20. [Inject]
  21. private FakeAggregate(IClock clock)
  22. {
  23. CorrectConstructorCalled = true;
  24. }
  25. public FakeAggregate(IClock clock, Guid id)
  26. {
  27. }
  28. }
  29. protected override void Given()
  30. {
  31. base.Given();
  32. var settings = new NinjectSettings {InjectNonPublic = true};
  33. IKernel kernel = new StandardKernel(settings);
  34. kernel.Bind<IClock>().To<DateTimeBasedClock>();
  35. _creationStrategy = new NinjectAggregateRootCreationStrategy(kernel);
  36. }
  37. protected override void When()
  38. {
  39. _aggregate = _creationStrategy.CreateAggregateRoot<FakeAggregate>();
  40. }
  41. [Then]
  42. public void it_doesnt_throw()
  43. {
  44. CaughtException.Should().BeNull();
  45. }
  46. [Then]
  47. public void it_creates_the_aggregate()
  48. {
  49. _aggregate.Should().NotBeNull();
  50. }
  51. [Then]
  52. public void it_calls_the_right_constructor()
  53. {
  54. _aggregate.CorrectConstructorCalled.Should().BeTrue();
  55. }
  56. }
  57. }