Ejemplo n.º 1
0
            public void GivenAnArrayOfValuesWhenSerializeCalledThenStreamPositionAdvances()
            {
                var array  = new[] { 1, 2, 3, 4, 5, 6 };
                var target = new XmlPrimitives.ArraySerializer(array.GetType());

                using (var memorStream = new MemoryStream())
                {
                    using (var writer = XmlWriter.Create(memorStream))
                    {
                        target.Serialize(array, writer);
                    }
                    Assert.IsTrue(memorStream.Position > 0);
                }
            }
Ejemplo n.º 2
0
            public void GivenAnArrayOfValuesWhenSerializeCalledThenStreamPositionAdvances()
            {
                var array = new[] { 1, 2, 3, 4, 5, 6 };
                var target = new XmlPrimitives.ArraySerializer(array.GetType());

                using (var memorStream = new MemoryStream())
                {
                    using (var writer = XmlWriter.Create(memorStream))
                    {
                        target.Serialize(array, writer);
                    }
                    Assert.IsTrue(memorStream.Position > 0);
                }
            }
Ejemplo n.º 3
0
            public void GivenASerializedArrayOfValuesWhenDeserializeCalledThenValidArrayIsReturned()
            {
                var array = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
                var target = new XmlPrimitives.ArraySerializer(array.GetType());
                using (var memoryStream = new MemoryStream())
                {
                    using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings { ConformanceLevel = ConformanceLevel.Fragment }))
                        target.Serialize(array, writer);
                    memoryStream.Position = 0;
                    Array result;
                    using (var reader = XmlReader.Create(memoryStream, new XmlReaderSettings { ConformanceLevel = ConformanceLevel.Fragment }))
                        result = target.Deserialize(reader);

                    CollectionAssert.AreEqual(array, result);
                }
            }
Ejemplo n.º 4
0
            public void GivenASerializedArrayOfValuesWhenDeserializeCalledThenValidArrayIsReturned()
            {
                var array  = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
                var target = new XmlPrimitives.ArraySerializer(array.GetType());

                using (var memoryStream = new MemoryStream())
                {
                    using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings {
                        ConformanceLevel = ConformanceLevel.Fragment
                    }))
                        target.Serialize(array, writer);
                    memoryStream.Position = 0;
                    Array result;
                    using (var reader = XmlReader.Create(memoryStream, new XmlReaderSettings {
                        ConformanceLevel = ConformanceLevel.Fragment
                    }))
                        result = target.Deserialize(reader);

                    CollectionAssert.AreEqual(array, result);
                }
            }