public void PackageDataContainer()
        {
            DataContainer container = DomainObjectIDs.Computer1.GetObject <Computer> ().InternalDataContainer;
            TransportItem item      = TransportItem.PackageDataContainer(container);

            CheckEqualData(container, item);
        }
Exemple #2
0
        public void SpecialStrategy()
        {
            TransportItem[] items;
            using (ClientTransaction.CreateRootTransaction().EnterNonDiscardingScope())
            {
                items = new[] { TransportItem.PackageDataContainer(DomainObjectIDs.Order1.GetObject <Order> ().InternalDataContainer) };
            }

            var repository   = new MockRepository();
            var strategyMock = repository.StrictMock <IImportStrategy>();
            var streamFake   = repository.Stub <Stream> ();

            strategyMock.Expect(mock => mock.Import(streamFake)).Return(items);

            strategyMock.Replay();

            var importer = DomainObjectImporter.CreateImporterFromStream(streamFake, strategyMock);
            TransportedDomainObjects result = importer.GetImportedObjects();

            Assert.That(
                result.TransportedObjects,
                Is.EquivalentTo(LifetimeService.GetObjects <Order> (result.DataTransaction, DomainObjectIDs.Order1)));

            strategyMock.VerifyAllExpectations();
        }
Exemple #3
0
        public void IntegrationTest_Properties()
        {
            DataContainer container        = DomainObjectIDs.Computer1.GetObject <Computer> ().InternalDataContainer;
            TransportItem item             = TransportItem.PackageDataContainer(container);
            TransportItem deserializedItem = SerializeAndDeserialize(item);

            TransportItemTest.CheckEqualData(container, deserializedItem);
        }
Exemple #4
0
        public void IntegrationTest_ID()
        {
            DataContainer container        = DomainObjectIDs.Computer1.GetObject <Computer> ().InternalDataContainer;
            TransportItem item             = TransportItem.PackageDataContainer(container);
            TransportItem deserializedItem = SerializeAndDeserialize(item);

            Assert.That(deserializedItem.ID, Is.EqualTo(container.ID));
        }
Exemple #5
0
        public void XmlSerialize_WithNullObjectID()
        {
            DataContainer container = DomainObjectIDs.Computer4.GetObject <Computer> ().InternalDataContainer;
            TransportItem item      = TransportItem.PackageDataContainer(container);

            byte[] serializedArray  = XmlSerializationHelper.XmlSerialize(new XmlTransportItem(item));
            string serializedString = Encoding.UTF8.GetString(serializedArray);

            Assert.That(serializedString, Is.EqualTo(XmlSerializationStrings.XmlForComputer4));
        }
Exemple #6
0
        public void IntegrationTest_ClassesWithAllDataTypes()
        {
            DataContainer container1 = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> ().InternalDataContainer;
            DataContainer container2 = DomainObjectIDs.ClassWithAllDataTypes2.GetObject <ClassWithAllDataTypes> ().InternalDataContainer;
            TransportItem item1      = TransportItem.PackageDataContainer(container1);
            TransportItem item2      = TransportItem.PackageDataContainer(container2);

            TransportItem[] deserializedItems = SerializeAndDeserialize(new[] { item1, item2 });

            TransportItemTest.CheckEqualData(container1, deserializedItems[0]);
            TransportItemTest.CheckEqualData(container2, deserializedItems[1]);
        }
Exemple #7
0
        public void IntegrationTest_Multiple()
        {
            DataContainer container1 = DomainObjectIDs.Computer1.GetObject <Computer> ().InternalDataContainer;
            DataContainer container2 = DomainObjectIDs.Computer2.GetObject <Computer> ().InternalDataContainer;
            TransportItem item1      = TransportItem.PackageDataContainer(container1);
            TransportItem item2      = TransportItem.PackageDataContainer(container2);

            TransportItem[] deserializedItems = SerializeAndDeserialize(new[] { item1, item2 });

            TransportItemTest.CheckEqualData(container1, deserializedItems[0]);
            TransportItemTest.CheckEqualData(container2, deserializedItems[1]);
        }
Exemple #8
0
        public void Export_SerializesData()
        {
            DataContainer expectedContainer1 = DomainObjectIDs.Order1.GetObject <Order> ().InternalDataContainer;
            DataContainer expectedContainer2 = DomainObjectIDs.Order3.GetObject <Order> ().InternalDataContainer;

            TransportItem item1 = TransportItem.PackageDataContainer(expectedContainer1);
            TransportItem item2 = TransportItem.PackageDataContainer(expectedContainer2);

            var items = new[] { item1, item2 };
            var versionIndependentItem1 = new KeyValuePair <string, Dictionary <string, object> > (item1.ID.ToString(), item1.Properties);
            var versionIndependentItem2 = new KeyValuePair <string, Dictionary <string, object> > (item2.ID.ToString(), item2.Properties);

            byte[] expectedData = Serializer.Serialize(new[] { versionIndependentItem1, versionIndependentItem2 });

            byte[] actualData = Export(items);
            Assert.That(actualData, Is.EqualTo(expectedData));
        }
Exemple #9
0
        public void Export_SerializesData()
        {
            DataContainer container1 = DomainObjectIDs.Order1.GetObject <Order> ().InternalDataContainer;
            DataContainer container2 = DomainObjectIDs.Order3.GetObject <Order> ().InternalDataContainer;

            TransportItem item1 = TransportItem.PackageDataContainer(container1);
            TransportItem item2 = TransportItem.PackageDataContainer(container2);

            var items = new[] { item1, item2 };

            using (var stream = new MemoryStream())
            {
                XmlExportStrategy.Instance.Export(stream, items);
                var actualString = ReplaceKnownXmlNamespaceDeclarations(Encoding.UTF8.GetString(stream.ToArray()));

                Assert.That(actualString, Is.EqualTo(ReplaceKnownXmlNamespaceDeclarations(XmlSerializationStrings.XmlForOrder1Order2)));
            }
        }