public void GetIdFrom_CalledWhenPropertyIsPrivate_ExpectValueOfPropertyIsReturned()
 {
     var id = StringGenerator.AnyNonNull();
     var aggregateRoot = new AggregateRootWithPrivateId(id);
     var getter = new TypedPropertyAggregateRootIdGetter<AggregateRootWithPrivateId, string>();
     getter.GetIdFrom(aggregateRoot).Should().BeSameAs(id);
 }
 public void GetIdFrom_CalledWhenPropertyIsNull_ExpectInvalidOperationException()
 {
     var aggregateRoot = new AggregateRoot { ObjectProperty = null };
     var getter = new TypedPropertyAggregateRootIdGetter<AggregateRoot, object>();
     getter.Invoking(x => x.GetIdFrom(aggregateRoot)).ShouldThrow<InvalidOperationException>();
 }
 public void GetIdFrom_CalledWhenPropertyIsShadowedAndAggregateRootIsBase_ExpectValueOfBasePropertyIsReturned()
 {
     var baseId = StringGenerator.AnyNonNull();
     var aggregateRoot = new AggregateRootWithShadowedId(baseId, StringGenerator.AnyNonNull());
     var getter = new TypedPropertyAggregateRootIdGetter<AggregateRootWithShadowedIdBase, string>();
     getter.GetIdFrom(aggregateRoot).Should().BeSameAs(baseId);
 }
 public void GetIdFrom_CalledWithNullAggregateRoot_ExpectArgumentNullExceptionWithCorrectParamName()
 {
     var getter = new TypedPropertyAggregateRootIdGetter<AggregateRoot, object>();
     getter.Invoking(x => x.GetIdFrom(null)).ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("aggregateRoot");
 }
 public void GetIdFrom_CalledWhenPropertyIsPublic_ExpectValueOfPropertyIsReturned()
 {
     var aggregateRoot = new AggregateRoot { StringProperty = StringGenerator.AnyNonNull() };
     var getter = new TypedPropertyAggregateRootIdGetter<AggregateRoot, string>();
     getter.GetIdFrom(aggregateRoot).Should().BeSameAs(aggregateRoot.StringProperty);
 }