Ejemplo n.º 1
0
        [Test] public void GetComponents()
        {
            DataObject    dataIn = new DataObject();
            TestComponent comp   = new TestComponent();

            Component[] outParam;

            dataIn.SetComponents(new[] { comp });

            Assert.IsTrue(dataIn.ContainsComponents(typeof(TestComponent), DataObjectStorage.Reference));
            Assert.IsTrue(dataIn.ContainsComponents(typeof(TestComponent), DataObjectStorage.Value));
            Assert.AreSame(comp, dataIn.GetComponents(typeof(TestComponent), DataObjectStorage.Reference)[0]);
            Assert.AreNotSame(comp, dataIn.GetComponents(typeof(TestComponent), DataObjectStorage.Value)[0]);

            Assert.IsTrue(dataIn.TryGetComponents(typeof(TestComponent), DataObjectStorage.Reference, out outParam));
            Assert.IsNotNull(outParam);
            Assert.IsTrue(dataIn.TryGetComponents(typeof(TestComponent), DataObjectStorage.Value, out outParam));
            Assert.IsNotNull(outParam);

            DataObject dataOut = this.SimulateClipboardSerialize(dataIn);

            Assert.IsTrue(dataOut.ContainsComponents(typeof(TestComponent), DataObjectStorage.Reference));
            Assert.IsTrue(dataOut.ContainsComponents(typeof(TestComponent), DataObjectStorage.Value));
            Assert.AreSame(comp, dataOut.GetComponents(typeof(TestComponent), DataObjectStorage.Reference)[0]);
            Assert.AreNotSame(comp, dataOut.GetComponents(typeof(TestComponent), DataObjectStorage.Value)[0]);

            Assert.IsTrue(dataOut.TryGetComponents(typeof(TestComponent), DataObjectStorage.Reference, out outParam));
            Assert.IsNotNull(outParam);
            Assert.IsTrue(dataOut.TryGetComponents(typeof(TestComponent), DataObjectStorage.Value, out outParam));
            Assert.IsNotNull(outParam);
        }