public void GetPropertyAccessExpression_BidirectionalMultipleRelation()
        {
            var propertyAccessor = _bidirectionalMultipleRelationReflector
                                   .GetPropertyAccessExpression(typeof(IMixinTypeWithDomainObjectAttributes_AnnotatedPropertiesPartOfInterface)).Compile();

            using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope())
            {
                var obj           = MixinTarget_AnnotatedPropertiesPartOfInterface.NewObject();
                var propertyValue = TestDomainObject.NewObject();
                ((IMixinTypeWithDomainObjectAttributes_AnnotatedPropertiesPartOfInterface)obj).BidirectionalMultiplePropertyWithMandatoryAttribute.Add(propertyValue);
                var result = propertyAccessor(obj);
                Assert.That(result, Is.EqualTo(new[] { propertyValue }));
            }
        }
        public void CommitValidate_WithValidationFailures()
        {
            using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope())
            {
                var domainObject1 = DomainObjectWithoutAnnotatedProperties.NewObject();
                var domainObject2 = TestDomainObject.NewObject();
                var domainObject3 = DomainObjectWithoutAnnotatedProperties.NewObject();

                var persistableData1 = new PersistableData(
                    domainObject1,
                    StateType.New,
                    DataContainerObjectMother.Create(domainObject1),
                    new IRelationEndPoint[0]);
                var persistableData2 = new PersistableData(
                    domainObject2,
                    StateType.Changed,
                    DataContainerObjectMother.Create(domainObject2),
                    new IRelationEndPoint[0]);
                var persistableData3 = new PersistableData(
                    domainObject3,
                    StateType.Deleted,
                    DataContainerObjectMother.Create(domainObject3),
                    new IRelationEndPoint[0]);

                _validatorBuilderMock
                .Expect(mock => mock.BuildValidator(typeof(DomainObjectWithoutAnnotatedProperties)))
                .Return(_validatorMock1);
                _validatorBuilderMock
                .Expect(mock => mock.BuildValidator(typeof(TestDomainObject)))
                .Return(_validatorMock2);

                var validationFailure1 = new ValidationFailure("Test1", "Error1");
                validationFailure1.SetValidatedInstance(domainObject1);
                var validationFailure2 = new ValidationFailure("Test2", "Error2");
                validationFailure2.SetValidatedInstance(domainObject1);
                var validationFailure3 = new ValidationFailure("Test3", "Error3");

                _validatorMock1.Expect(mock => mock.Validate(domainObject1)).Return(new ValidationResult(new [] { validationFailure1 }));
                _validatorMock2.Expect(mock => mock.Validate(domainObject2)).Return(new ValidationResult(new [] { validationFailure2, validationFailure3 }));

                _extension.CommitValidate(ClientTransaction.Current, Array.AsReadOnly(new[] { persistableData1, persistableData2, persistableData3 }));

                _validatorBuilderMock.VerifyAllExpectations();
                _validatorMock1.VerifyAllExpectations();
                _validatorMock2.VerifyAllExpectations();
            }
        }