public void SetAggregateRoot_with_aggregateRoot_null_throws_ArgumentNullException() { var child = new ChildEntity(); ((Action)(() => ((IChildEntityInternal)child).SetAggregateRoot(null, ChildEntityId.Generate()))).Should().Throw <ArgumentNullException>() .And.ParamName.Should().Be("aggregateRoot"); }
public void SetAggregateRoot_cannot_be_used_twice() { var child = new ChildEntity(); ((IChildEntityInternal)child).SetAggregateRoot(new ParentEntity(ParentEntityId.Generate(), "name"), ChildEntityId.Generate()); ((Action)(() => ((IChildEntityInternal)child).SetAggregateRoot(new ParentEntity(ParentEntityId.Generate(), "name"), ChildEntityId.Generate()))).Should().Throw <InvalidOperationException>() .And.Message.Should().Be("AggregateRoot cannot be reassigned in ChildEntity!"); }