public static TransportedDomainObjects Import(byte[] binaryData)
 {
     using (var stream = new MemoryStream(binaryData))
     {
         return(DomainObjectImporter.CreateImporterFromStream(stream, BinaryImportStrategy.Instance).GetImportedObjects());
     }
 }
示例#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();
        }