Пример #1
0
        public void Execute_NullDataContainer()
        {
            var command = new MultiDataContainerAssociateWithIDsCommand(new[] { DomainObjectIDs.Order1 }, _commandStub);

            _commandStub.Stub(stub => stub.Execute(_executionContext)).Return(new[] { _order1Container, null });

            var result = command.Execute(_executionContext).ToList();

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0].LocatedObject, Is.SameAs(_order1Container));
            Assert.That(result[0].ObjectID, Is.EqualTo(DomainObjectIDs.Order1));
        }
Пример #2
0
        public void Execute_DataContainersNotMatchingAnyID()
        {
            var wrongID1 = new ObjectID(typeof(OrderItem), _order1Container.ID.Value);
            var wrongID2 = new ObjectID(typeof(OrderTicket), _order1Container.ID.Value);

            var command = new MultiDataContainerAssociateWithIDsCommand(new[] { wrongID1, wrongID1, wrongID2, _order3Container.ID }, _commandStub);

            _commandStub.Stub(stub => stub.Execute(_executionContext)).Return(new[] { _order1Container, _order2Container, _order3Container });

            Assert.That(
                () => command.Execute(_executionContext).ToList(),
                Throws.TypeOf <PersistenceException>().With.Message.EqualTo(
                    "The ObjectID of one or more loaded DataContainers does not match the expected ObjectIDs:\r\n"
                    + "Loaded DataContainer ID: Order|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid, expected ObjectID(s): "
                    + "OrderItem|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid, OrderTicket|5682f032-2f0b-494b-a31c-c97f02b89c36|System.Guid\r\n"
                    + "Loaded DataContainer ID: Order|83445473-844a-4d3f-a8c3-c27f8d98e8ba|System.Guid, expected ObjectID(s): none"));
        }