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

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

#
C# | 36 lines | 32 code | 4 blank | 0 comment | 0 complexity | 719108bedc1098146192654547023954 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_stateless_aggregated_root_that_has_events : given.a_repository_for_a_stateless_aggregated_root
  8. {
  9. static Guid aggregated_root_id = Guid.NewGuid();
  10. static Guid event_id = Guid.NewGuid();
  11. static SimpleStatelessAggregatedRoot stateless_aggregated_root;
  12. static CommittedEventStream event_stream;
  13. static EventSourceVersion expected_version;
  14. static EventSourceVersion version_of_last_event;
  15. Establish context = () =>
  16. {
  17. version_of_last_event = new EventSourceVersion(1,1);
  18. expected_version = new EventSourceVersion(2, 0);
  19. event_store_mock.Setup(e => e.GetLastCommittedVersion(typeof(SimpleStatelessAggregatedRoot),aggregated_root_id)).Returns(version_of_last_event);
  20. };
  21. Because of = () => stateless_aggregated_root = repository.Get(aggregated_root_id);
  22. It should_return_an_instance = () => stateless_aggregated_root.ShouldNotBeNull();
  23. It should_not_get_events_for_the_aggregated_root = () => event_store_mock.Verify(e => e.Load(typeof(SimpleStatelessAggregatedRoot), aggregated_root_id),Moq.Times.Never());
  24. It should_not_re_apply_events_for_the_aggregated_root = () => stateless_aggregated_root .ReApplyCalled.ShouldBeFalse();
  25. It should_ensure_the_event_source_has_the_correct_version = () =>
  26. {
  27. event_store_mock.Verify(e => e.GetLastCommittedVersion(typeof(SimpleStatelessAggregatedRoot), aggregated_root_id), Moq.Times.Once());
  28. stateless_aggregated_root.Version.ShouldEqual(expected_version);
  29. };
  30. It should_register_the_aggregate_root_for_tracking_within_this_context = () => command_context_mock.Verify(cc => cc.RegisterForTracking(stateless_aggregated_root));
  31. }
  32. }