public void Creating_instance_should_succeed_when_type_is_subclass_of_AggregateRoot_and_has_default_ctor() { var correctType = typeof(AggRootWithDefaultCtor); var creator = new SimpleAggregateRootCreationStrategy(); creator.CreateAggregateRoot(correctType); }
public AggregateRootTestFixture() : base() { Guid commitId = Guid.NewGuid(); Guid sourceId = Guid.NewGuid(); CreationStrategy = new SimpleAggregateRootCreationStrategy(); AggregateRoot = CreationStrategy.CreateAggregateRoot <TAggregateRoot>(); PublishedEvents = new List <UncommittedEvent>(); var history = Given(); if (history != null) { long sequence = 0; var stream = Prepare.Events(history).ForSource(AggregateRoot.EventSourceId); AggregateRoot.InitializeFromHistory(stream); } try { AggregateRoot.EventApplied += (s, e) => PublishedEvents.Add(e.Event); When(); } catch (Exception exception) { CaughtException = exception; } finally { Finally(); } }
[SetUp] // TODO: Testdriven.net debug runner doesn't recognize inhiret attributes. Use native for now. public void Setup() { CreationStrategy = new SimpleAggregateRootCreationStrategy(); AggregateRoot = CreationStrategy.CreateAggregateRoot <TAggregateRoot>(); PublishedEvents = new SourcedEvent[0]; var history = Given(); if (history != null) { AggregateRoot.InitializeFromHistory(history); } try { When(); PublishedEvents = AggregateRoot.GetUncommittedEvents(); } catch (Exception exception) { CaughtException = exception; } finally { Finally(); } }
public void Creation_result_by_correct_type_should_be_of_specified_type() { var correctType = typeof(AggRootWithDefaultCtor); var creator = new SimpleAggregateRootCreationStrategy(); var result = creator.CreateAggregateRoot(correctType); result.Should().BeOfType <AggRootWithDefaultCtor>(); }
public void Creation_result_by_correct_type_should_not_be_null() { var correctType = typeof(AggRootWithDefaultCtor); var creator = new SimpleAggregateRootCreationStrategy(); var result = creator.CreateAggregateRoot(correctType); result.Should().NotBeNull(); }
public void Creating_non_aggregate_root_type_should_throw() { var wrongType = typeof(Stream); var creator = new SimpleAggregateRootCreationStrategy(); Action act = () => creator.CreateAggregateRoot(wrongType); act.ShouldThrow <ArgumentException>().And.ParamName.Should().Be("aggregateRootType"); }
public void Creating_without_default_ctor_should_throw() { var wrongType = typeof(AggRootWithoutDefaultCtor); var creator = new SimpleAggregateRootCreationStrategy(); Action act = () => creator.CreateAggregateRoot(wrongType); act.ShouldThrow <AggregateRootCreationException>().And.Message.Should().Contain(wrongType.FullName); }