PageRenderTime 36ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/Bifrost.Specs/Domain/for_AggregatedRootRepository/when_getting_a_stateful_aggregated_root_that_has_no_events.cs

#
C# | 32 lines | 28 code | 4 blank | 0 comment | 0 complexity | e2e54bd9eb1a7d57c79a14cd683a3854 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using Bifrost.Events;
  3. using Machine.Specifications;
  4. namespace Bifrost.Specs.Domain.for_AggregatedRootRepository
  5. {
  6. [Subject(Subjects.getting_aggregated_root)]
  7. public class when_getting_a_stateful_aggregated_root_that_has_no_events : given.a_repository_for_a_stateful_aggregated_root
  8. {
  9. static Guid aggregated_root_id = Guid.NewGuid();
  10. static Guid event_id = Guid.NewGuid();
  11. static SimpleStatefulAggregatedRoot stateful_aggregated_root;
  12. static CommittedEventStream event_stream;
  13. static EventSourceVersion expected_version;
  14. Establish context = () =>
  15. {
  16. expected_version = new EventSourceVersion(0,0);
  17. event_stream = new CommittedEventStream(aggregated_root_id);
  18. event_store_mock.Setup(e => e.Load(Moq.It.IsAny<Type>(), Moq.It.IsAny<Guid>())).Returns(
  19. event_stream);
  20. };
  21. Because of = () => stateful_aggregated_root = repository.Get(aggregated_root_id);
  22. It should_return_an_instance = () => stateful_aggregated_root.ShouldNotBeNull();
  23. It should_get_events_for_the_aggregated_root = () => event_store_mock.Verify(e => e.Load(typeof(SimpleStatefulAggregatedRoot), aggregated_root_id));
  24. It should_not_re_apply_any_events_for_the_aggregated_root = () => stateful_aggregated_root.ReApplyCalled.ShouldBeFalse();
  25. It should_be_the_initial_version = () => stateful_aggregated_root.Version.ShouldEqual(expected_version);
  26. It should_register_the_aggregate_root_for_tracking_within_this_context = () => command_context_mock.Verify(cc => cc.RegisterForTracking(stateful_aggregated_root));
  27. }
  28. }