public void Execute() { var command = new MultiDataContainerAssociateWithIDsCommand(new[] { DomainObjectIDs.Order1, DomainObjectIDs.Order3, DomainObjectIDs.OrderItem1 }, _commandStub); _commandStub.Stub(stub => stub.Execute(_executionContext)).Return(new[] { _order2Container, _order1Container }); var result = command.Execute(_executionContext).ToList(); Assert.That(result.Count, Is.EqualTo(3)); Assert.That(result[0].LocatedObject, Is.SameAs(_order1Container)); Assert.That(result[0].ObjectID, Is.EqualTo(DomainObjectIDs.Order1)); Assert.That(result[1].LocatedObject, Is.SameAs(_order2Container)); Assert.That(result[1].ObjectID, Is.EqualTo(DomainObjectIDs.Order3)); Assert.That(result[2].LocatedObject, Is.Null); Assert.That(result[2].ObjectID, Is.EqualTo(DomainObjectIDs.OrderItem1)); }
public override void SetUp() { base.SetUp(); _fakeResult = new ObjectLookupResult <DataContainer> [0]; _objectID1 = DomainObjectIDs.Order1; _objectID2 = DomainObjectIDs.Order3; _commandExecutionContextStub = MockRepository.GenerateStub <IRdbmsProviderCommandExecutionContext>(); _commandExecutionContextStub = MockRepository.GenerateStub <IRdbmsProviderCommandExecutionContext>(); _objectIDLoadCommandStub = MockRepository.GenerateStub <IStorageProviderCommand <IEnumerable <ObjectID>, IRdbmsProviderCommandExecutionContext> >(); _objectIDLoadCommandStub.Stub(stub => stub.Execute(_commandExecutionContextStub)).Return(new[] { _objectID1, _objectID2 }); _dataContainerLoadCommandStub = MockRepository.GenerateStub <IStorageProviderCommand <ObjectLookupResult <DataContainer>[], IRdbmsProviderCommandExecutionContext> >(); _dataContainerLoadCommandStub.Stub(stub => stub.Execute(_commandExecutionContextStub)).Return(_fakeResult); _storageProviderFactoryStub = MockRepository.GenerateStub <IStorageProviderCommandFactory <IRdbmsProviderCommandExecutionContext> >(); _storageProviderFactoryStub .Stub(stub => stub.CreateForSortedMultiIDLookup(Arg <ObjectID[]> .List.Equal(new[] { _objectID1, _objectID2 }))) .Return(_dataContainerLoadCommandStub); _loadCommand = new IndirectDataContainerLoadCommand(_objectIDLoadCommandStub, _storageProviderFactoryStub); }