Пример #1
0
        public void TestRoundTripElementSerialisationForMultipleIDs()
        {
            IFormatter formatter = new SoapFormatter();

            // Create an instance of the type and serialize it.
            var elementIDs = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            //Serialise to a test memory stream
            var m = new MemoryStream();

            formatter.Serialize(m, elementIDs);
            m.Flush();

            //Reset the stream
            m.Seek(0, SeekOrigin.Begin);

            //Readback
            var readback = (MultipleSerializableId)formatter.Deserialize(m);

            //Verify that the data is correct
            Assert.IsTrue(readback.IntIDs.Count == 2);
            Assert.IsTrue(readback.IntIDs[0] == 42);
            Assert.IsTrue(readback.IntIDs[1] == 20);
            Assert.IsTrue(readback.StringIDs.Count == 2);
            Assert.IsTrue(readback.StringIDs[0].Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
            Assert.IsTrue(readback.StringIDs[1].Equals("{A79294BF-6D27-4B86-BEE9-D6921C11D495}"));
        }
Пример #2
0
        public void RawTraceInteractionTestWithMultipleIDs()
        {
            var elementIDs = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            //Raw write
            ElementBinder.SetRawDataForTrace(elementIDs);
            elementIDs = null;

            //Readback
            var readback = (MultipleSerializableId)ElementBinder.GetRawDataFromTrace();

            //Verify that the data is correct
            Assert.IsTrue(readback.IntIDs.Count == 2);
            Assert.IsTrue(readback.IntIDs[0] == 42);
            Assert.IsTrue(readback.IntIDs[1] == 20);
            Assert.IsTrue(readback.StringIDs.Count == 2);
            Assert.IsTrue(readback.StringIDs[0].Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
            Assert.IsTrue(readback.StringIDs[1].Equals("{A79294BF-6D27-4B86-BEE9-D6921C11D495}"));
        }
Пример #3
0
        public void TwoInstancesOfMultSerializableIdAreEqual()
        {
            var elementIDs = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            var elementIDs2 = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            //Raw write
            ElementBinder.SetRawDataForTrace(elementIDs);
            elementIDs = null;

            //Readback
            var readback = (MultipleSerializableId)ElementBinder.GetRawDataFromTrace();

            //verify that the id extracted from trace is equal to the new instance
            Assert.IsTrue(readback.Equals(elementIDs2));
        }
Пример #4
0
        public void RawTraceInteractionTestWithMultipleIDs()
        {
            var elementIDs = new MultipleSerializableId
            {
                IntIDs = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            //Raw write
            ElementBinder.SetRawDataForTrace(elementIDs);
            elementIDs = null;

            //Readback
            var readback = (MultipleSerializableId)ElementBinder.GetRawDataFromTrace();

            //Verify that the data is correct
            Assert.IsTrue(readback.IntIDs.Count == 2);
            Assert.IsTrue(readback.IntIDs[0] == 42);
            Assert.IsTrue(readback.IntIDs[1] == 20);
            Assert.IsTrue(readback.StringIDs.Count == 2);
            Assert.IsTrue(readback.StringIDs[0].Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
            Assert.IsTrue(readback.StringIDs[1].Equals("{A79294BF-6D27-4B86-BEE9-D6921C11D495}"));
        }
Пример #5
0
        public void TestRoundTripElementSerialisationForMultipleIDs()
        {
            IFormatter formatter = new SoapFormatter();

            // Create an instance of the type and serialize it.
            var elementIDs = new MultipleSerializableId
            {
                IntIDs = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            //Serialise to a test memory stream
            var m = new MemoryStream();
            formatter.Serialize(m, elementIDs);
            m.Flush();

            //Reset the stream
            m.Seek(0, SeekOrigin.Begin);

            //Readback
            var readback = (MultipleSerializableId)formatter.Deserialize(m);

            //Verify that the data is correct
            Assert.IsTrue(readback.IntIDs.Count == 2);
            Assert.IsTrue(readback.IntIDs[0] == 42);
            Assert.IsTrue(readback.IntIDs[1] == 20);
            Assert.IsTrue(readback.StringIDs.Count == 2);
            Assert.IsTrue(readback.StringIDs[0].Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
            Assert.IsTrue(readback.StringIDs[1].Equals("{A79294BF-6D27-4B86-BEE9-D6921C11D495}"));
        }