public void MoveNext_WithNonLastPropertyNotReferenceProperty_ContinuesEnumeration_SetsCurrentNull() { var firstClassStub = CreateClassStub(); var secondClassStub = CreateClassStub(); secondClassStub.Stub(_ => _.Identifier).Return("SecondClass"); var firstPropertyStub = CreateReferencePropertyStub(firstClassStub, "FirstProperty", secondClassStub); var enumerator = new DynamicBusinessObjectPropertyPathPropertyEnumerator("FirstProperty:SecondProperty:ThirdProperty"); Assert.That(enumerator.MoveNext(firstClassStub), Is.True); Assert.That(enumerator.Current, Is.SameAs(firstPropertyStub)); Assert.That(enumerator.MoveNext(secondClassStub), Is.True); Assert.That(enumerator.Current, Is.Null); }
public void MoveNext_WithMultipleProperties() { var firstClassStub = CreateClassStub(); var secondClassStub = CreateClassStub(); var thirdClassStub = CreateClassStub(); var firstPropertyStub = CreateReferencePropertyStub(firstClassStub, "FirstProperty", secondClassStub); var secondPropertyStub = CreateReferencePropertyStub(secondClassStub, "SecondProperty", thirdClassStub); var thirdPropertyStub = CreatePropertyStub(thirdClassStub, "ThirdProperty"); var enumerator = new DynamicBusinessObjectPropertyPathPropertyEnumerator("FirstProperty:SecondProperty:ThirdProperty"); Assert.That(enumerator.MoveNext(firstClassStub), Is.True); Assert.That(enumerator.Current, Is.SameAs(firstPropertyStub)); Assert.That(enumerator.MoveNext(secondClassStub), Is.True); Assert.That(enumerator.Current, Is.SameAs(secondPropertyStub)); Assert.That(enumerator.MoveNext(thirdClassStub), Is.True); Assert.That(enumerator.Current, Is.SameAs(thirdPropertyStub)); Assert.That(enumerator.MoveNext(MockRepository.GenerateStub <IBusinessObjectClass>()), Is.False); Assert.That(() => enumerator.Current, Throws.InvalidOperationException.With.Message.EqualTo("Enumeration already finished.")); }