コード例 #1
0
 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);
 }
コード例 #2
0
 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>();
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 public void GetIdFrom_CalledWithNullAggregateRoot_ExpectArgumentNullExceptionWithCorrectParamName()
 {
     var getter = new TypedPropertyAggregateRootIdGetter<AggregateRoot, object>();
     getter.Invoking(x => x.GetIdFrom(null)).ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("aggregateRoot");
 }
コード例 #5
0
 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);
 }