Ejemplo n.º 1
0
        public void AssociatedEndPointID()
        {
            var endPointID = RelationEndPointID.Create(DomainObjectIDs.Customer1, typeof(Customer), "Orders");

            _wrappedDataStub.Stub(stub => stub.AssociatedEndPointID).Return(endPointID);

            Assert.That(_readOnlyDecorator.AssociatedEndPointID, Is.SameAs(endPointID));
        }
Ejemplo n.º 2
0
        public override void SetUp()
        {
            base.SetUp();

            _collectionProviderMock = MockRepository.GenerateStrictMock <ICollectionEndPointCollectionProvider>();
            _associatedCollectionDataStrategyFactoryMock = MockRepository.GenerateStrictMock <IAssociatedCollectionDataStrategyFactory>();
            _endPointID = RelationEndPointID.Create(DomainObjectIDs.Customer1, typeof(Customer), "Orders");

            _manager = new CollectionEndPointCollectionManager(_endPointID, _collectionProviderMock, _associatedCollectionDataStrategyFactoryMock);

            _associatedDataStrategyStub = MockRepository.GenerateStub <IDomainObjectCollectionData> ();
            _associatedDataStrategyStub.Stub(stub => stub.RequiredItemType).Return(typeof(Order));
            _associatedDataStrategyStub.Stub(stub => stub.AssociatedEndPointID).Return(_endPointID);
        }
        public void GetCollection()
        {
            _associatedCollectionDataStrategyFactoryMock
            .Expect(mock => mock.CreateDataStrategyForEndPoint(_endPointID))
            .Return(_dataStrategyStub);
            _associatedCollectionDataStrategyFactoryMock.Replay();

            _dataStrategyStub.Stub(stub => stub.AssociatedEndPointID).Return(_endPointID);

            var result = _provider.GetCollection(_endPointID);

            _associatedCollectionDataStrategyFactoryMock.VerifyAllExpectations();
            Assert.That(result, Is.TypeOf <OrderCollection> ());
            Assert.That(DomainObjectCollectionDataTestHelper.GetDataStrategy(result), Is.SameAs(_dataStrategyStub));

            Assert.That(result, Is.SameAs(_provider.GetCollection(_endPointID)));
        }
Ejemplo n.º 4
0
        public void IsDataComplete()
        {
            _dataStrategyMock.Stub(mock => mock.IsDataComplete).Return(true);
            Assert.That(_collectionWithDataStrategyMock.IsDataComplete, Is.True);

            _dataStrategyMock.BackToRecord();
            _dataStrategyMock.Stub(mock => mock.IsDataComplete).Return(false);
            Assert.That(_collectionWithDataStrategyMock.IsDataComplete, Is.False);
        }
Ejemplo n.º 5
0
        public void Remove_HoldsObjectFromOtherTransaction()
        {
            _wrappedDataMock.Stub(stub => stub.GetObject(DomainObjectIDs.Order1)).Return(_order3);

            CheckThrows <ArgumentException> (
                () => _modificationCheckingDecorator.Remove(_order1),
                "The object to be removed has the same ID as an object in this collection, but is a different object reference.\r\nParameter name: domainObject");

            _wrappedDataMock.AssertWasNotCalled(mock => mock.Remove(Arg <DomainObject> .Is.Anything));
        }
Ejemplo n.º 6
0
 private void StubEmptyDataStrategy(IDomainObjectCollectionData dataStrategyStub)
 {
     dataStrategyStub.Stub(stub => stub.GetEnumerator()).Return(Enumerable.Empty <DomainObject> ().GetEnumerator());
 }
        public void Count()
        {
            _endPointDataStub.Stub(stub => stub.Count).Return(42);
            _collectionEndPointMock.Expect(mock => mock.GetData()).Return(_endPointDataDecorator);
            _collectionEndPointMock.Replay();

            Assert.That(_delegatingData.Count, Is.EqualTo(42));

            _collectionEndPointMock.VerifyAllExpectations();
        }