private void when_create() { act = () => _target = new AggregateUnderTest(_id); it["is identified with id"] = () => _target.ProvidedId.ShouldBe(_id); context["and id is empty"] = () => { before = () => _id = null; it["throws exception"] = expect <ArgumentOutOfRangeException>( "Specified argument was out of the range of valid values.\r\nParameter name: id" ); }; }
private void when_create() { act = () => _target = new AggregateUnderTest(_id); it["is identified with id"] = () => _target.ProvidedId.ShouldBe(_id); context["and id is empty"] = () => { before = () => _id = Guid.Empty; it["throws exception"] = expect <ArgumentOutOfRangeException>( "Specified argument was out of the range of valid values.\r\nParameter name: id" ); }; context["then hydrate"] = () => { act = () => _target.Hydrate(_eventsToHydrate); it["handles hydrated events"] = () => { _target.HydratedEvents.Count.ShouldBe(2); }; it["handles hydrated events in correct order"] = () => { _target.HydratedEvents[0].Index.ShouldBe(1); _target.HydratedEvents[1].Index.ShouldBe(2); }; context["and events to hydrate are null"] = () => { before = () => _eventsToHydrate = null; it["throws exception"] = expect <ArgumentNullException>( "Value cannot be null.\r\nParameter name: events" ); }; context["then apply"] = () => { act = () => _target.ApplyTwoTimes(); it["handles applied events"] = () => { _target.AppliedEvents.Count.ShouldBe(2); }; context["and action to apply is null"] = () => { act = () => _target.ApplyNull(); it["throws exception"] = expect <ArgumentNullException>( "Value cannot be null.\r\nParameter name: action" ); }; context["then flush"] = () => { act = () => _flushedEvents = _target.Flush(); it["flushes applied events"] = () => { _flushedEvents.Count.ShouldBe(_target.AppliedEvents.Count); foreach (var @event in _flushedEvents) { @event.Body.ShouldBeOfType <AppliedEvent>(); } }; it["flushes applied events with versions after hydrated events"] = () => { _flushedEvents[0].Version.ShouldBe(3); _flushedEvents[1].Version.ShouldBe(4); }; it["flushes applied events in correct order"] = () => { ((AppliedEvent)_flushedEvents[0].Body).Index.ShouldBe(1); ((AppliedEvent)_flushedEvents[1].Body).Index.ShouldBe(2); }; context["then flush again"] = () => { act = () => _flushedEvents = _target.Flush(); it["flushes no events"] = () => _flushedEvents.Count.ShouldBe(0); }; }; }; }; }
private void before_each() { _id = "some id"; _target = _aggregate = new AggregateUnderTest(_id); _registerer = new FakeIRegisterStreams(); }
private void before_each() { _id = "some id"; _target = _aggregate = new AggregateUnderTest(_id); _streams = new FakeIHydrateStreams(); }