Exemplo n.º 1
0
        public void AssociateCollectionWithEndPoint_RemembersTheNewCollectionAsCurrent()
        {
            var oldCollection = RegisterAssociatedOriginalCollection();
            var newCollection = new DomainObjectCollection();

            _associatedCollectionDataStrategyFactoryMock.Stub(stub => stub.CreateDataStrategyForEndPoint(_endPointID)).Return(_associatedDataStrategyStub);

            _manager.AssociateCollectionWithEndPoint(newCollection);

            Assert.That(_manager.GetCurrentCollectionReference(), Is.SameAs(newCollection));
            Assert.That(_manager.GetOriginalCollectionReference(), Is.SameAs(oldCollection));
        }
        public void GetCollection_CollectionWithWrongCtor()
        {
            var classDefinition            = GetTypeDefinition(typeof(DomainObjectWithCollectionMissingCtor));
            var relationEndPointDefinition = GetEndPointDefinition(typeof(DomainObjectWithCollectionMissingCtor), "OppositeObjects");
            var endPointID = RelationEndPointID.Create(new ObjectID(classDefinition, Guid.NewGuid()), relationEndPointDefinition);

            _associatedCollectionDataStrategyFactoryMock
            .Stub(mock => mock.CreateDataStrategyForEndPoint(endPointID))
            .Return(_dataStrategyStub);

            Assert.That(() => _provider.GetCollection(endPointID), Throws.TypeOf <MissingMethodException> ()
                        .With.Message.ContainsSubstring("does not provide a constructor taking an IDomainObjectCollectionData object"));
        }