Exemple #1
0
        public void LoadDataContainers()
        {
            var objectID1 = DomainObjectIDs.Order1;
            var objectID2 = DomainObjectIDs.Order3;
            var objectID3 = DomainObjectIDs.Order4;

            var lookupResult1 = new ObjectLookupResult <DataContainer> (objectID1, DataContainer.CreateNew(objectID1));
            var lookupResult2 = new ObjectLookupResult <DataContainer> (objectID2, DataContainer.CreateNew(objectID2));
            var lookupResult3 = new ObjectLookupResult <DataContainer> (objectID3, DataContainer.CreateNew(objectID3));

            var commandMock =
                _mockRepository.StrictMock <IStorageProviderCommand <IEnumerable <ObjectLookupResult <DataContainer> >, IRdbmsProviderCommandExecutionContext> >();

            using (_mockRepository.Ordered())
            {
                _connectionCreatorMock.Expect(mock => mock.CreateConnection()).Return(_connectionStub);
                _commandFactoryMock
                .Expect(mock => mock.CreateForSortedMultiIDLookup(Arg <IEnumerable <ObjectID> > .List.Equal(new[] { objectID1, objectID2, objectID3 })))
                .Return(commandMock);
                commandMock.Expect(mock => mock.Execute(_provider)).Return(new[] { lookupResult1, lookupResult2, lookupResult3 });
            }
            _mockRepository.ReplayAll();

            var result = _provider.LoadDataContainers(new[] { objectID1, objectID2, objectID3 }).ToArray();

            _mockRepository.VerifyAll();
            Assert.That(result, Is.EqualTo(new[] { lookupResult1, lookupResult2, lookupResult3 }));
        }
 private ILoadedObjectData GetLoadedObjectDataForObjectLookupResult(ObjectLookupResult <DataContainer> result)
 {
     if (result.LocatedObject == null)
     {
         return(new NotFoundLoadedObjectData(result.ObjectID));
     }
     else
     {
         return(new FreshlyLoadedObjectData(result.LocatedObject));
     }
 }
Exemple #3
0
        public void LoadDataContainer()
        {
            var objectID   = DomainObjectIDs.Order1;
            var fakeResult = new ObjectLookupResult <DataContainer> (objectID, DataContainer.CreateNew(objectID));

            var commandMock =
                _mockRepository.StrictMock <IStorageProviderCommand <ObjectLookupResult <DataContainer>, IRdbmsProviderCommandExecutionContext> >();

            using (_mockRepository.Ordered())
            {
                _connectionCreatorMock.Expect(mock => mock.CreateConnection()).Return(_connectionStub);
                _commandFactoryMock
                .Expect(mock => mock.CreateForSingleIDLookup(objectID))
                .Return(commandMock);
                commandMock.Expect(mock => mock.Execute(_provider)).Return(fakeResult);
            }
            _mockRepository.ReplayAll();

            var result = _provider.LoadDataContainer(objectID);

            _mockRepository.VerifyAll();
            Assert.That(result, Is.EqualTo(fakeResult));
        }