Пример #1
0
        public void LoadNew()
        {
            var order = (Order)_transporter.LoadNew(typeof(Order), ParamList.Empty);

            Assert.That(order, Is.Not.Null);
            Assert.That(_transporter.IsLoaded(order.ID), Is.True);
        }
Пример #2
0
        public void ChangedBySource_RelatedObjectToNew()
        {
            var transporter = new DomainObjectTransporter();
            var computer    = (Computer)transporter.LoadNew(typeof(Computer), ParamList.Empty);
            var employee    = (Employee)transporter.LoadNew(typeof(Employee), ParamList.Empty);

            computer.Employee = employee;

            byte[] binaryData = DomainObjectTransporterTestHelper.GetBinaryDataFor(transporter);
            var    imported   = DomainObjectTransporterTestHelper.ImportObjects(binaryData);

            var loadedObject1 = (Computer)imported.Find(obj => obj is Computer);
            var loadedObject2 = (Employee)imported.Find(obj => obj is Employee);

            Assert.That(loadedObject1.Employee, Is.SameAs(loadedObject2));
        }
Пример #3
0
        public void NonExistingObjects_NewInSource()
        {
            var transporter   = new DomainObjectTransporter();
            var outerComputer = (Computer)transporter.LoadNew(typeof(Computer), ParamList.Empty);

            byte[] binaryData = DomainObjectTransporterTestHelper.GetBinaryDataFor(transporter);

            var imported = DomainObjectTransporterTestHelper.ImportObjects(binaryData);

            Assert.That(imported[0].State, Is.EqualTo(StateType.New));
            Assert.That(imported[0].ID, Is.EqualTo(outerComputer.ID));
        }
Пример #4
0
        public void OnObjectImportedCallback()
        {
            var transporter = new DomainObjectTransporter();
            var instance    = (DomainObjectWithImportCallback)transporter.LoadNew(typeof(DomainObjectWithImportCallback), ParamList.Empty);

            instance.Property = 17;

            byte[] binaryData = DomainObjectTransporterTestHelper.GetBinaryDataFor(transporter);

            var facade = RootPersistenceStrategyMockFacade.CreateWithStrictMock();

            facade.ExpectLoadObjectData(new[] { instance.ID });
            using (facade.CreateScope())
            {
                var imported = DomainObjectTransporterTestHelper.ImportObjects(binaryData);

                var importedInstance = (DomainObjectWithImportCallback)imported.Single();
                Assert.That(importedInstance.CallbackCalled, Is.True);
                Assert.That(importedInstance.PropertyValueInCallback, Is.EqualTo(17));
                Assert.That(importedInstance.CallbackTransaction, Is.SameAs(importedInstance.RootTransaction));
            }
        }