PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms 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
 1using System;
 2using Bifrost.Events;
 3using Machine.Specifications;
 4
 5namespace Bifrost.Specs.Domain.for_AggregatedRootRepository
 6{
 7    [Subject(Subjects.getting_aggregated_root)]
 8    public class when_getting_a_stateful_aggregated_root_that_has_no_events : given.a_repository_for_a_stateful_aggregated_root
 9    {
10        static Guid aggregated_root_id = Guid.NewGuid();
11        static Guid event_id = Guid.NewGuid();
12        static SimpleStatefulAggregatedRoot stateful_aggregated_root;
13        static CommittedEventStream event_stream;
14        static EventSourceVersion expected_version;
15
16        Establish context = () =>
17                                {
18                                    expected_version = new EventSourceVersion(0,0);
19                                    event_stream = new CommittedEventStream(aggregated_root_id);
20                                    event_store_mock.Setup(e => e.Load(Moq.It.IsAny<Type>(), Moq.It.IsAny<Guid>())).Returns(
21                                        event_stream);
22                                };
23
24        Because of = () => stateful_aggregated_root = repository.Get(aggregated_root_id);
25
26        It should_return_an_instance = () => stateful_aggregated_root.ShouldNotBeNull();
27        It should_get_events_for_the_aggregated_root = () => event_store_mock.Verify(e => e.Load(typeof(SimpleStatefulAggregatedRoot), aggregated_root_id));
28        It should_not_re_apply_any_events_for_the_aggregated_root = () => stateful_aggregated_root.ReApplyCalled.ShouldBeFalse();
29        It should_be_the_initial_version = () => stateful_aggregated_root.Version.ShouldEqual(expected_version);
30        It should_register_the_aggregate_root_for_tracking_within_this_context = () => command_context_mock.Verify(cc => cc.RegisterForTracking(stateful_aggregated_root));
31    }
32}