Exemplo n.º 1
0
        public void NestedAttributedObjectCanRoundTrip(
            XmlContentSerializer sut,
            XmlAttributedChangeset changeset,
            XmlAttributedTestEventX tex,
            XmlAttributedTestEventY tey)
        {
            changeset.Items = new object[] { tex, tey };

            using (var ms = new MemoryStream())
                using (var w = XmlWriter.Create(ms))
                {
                    sut.Serialize(w, changeset);
                    w.Flush();
                    ms.Position = 0;
                    using (var r = XmlReader.Create(ms))
                    {
                        var content = sut.Deserialize(r);

                        var actual = Assert.IsAssignableFrom <XmlAttributedChangeset>(content.Item);
                        Assert.Equal(changeset.Id, actual.Id);
                        var actualTex = Assert.IsAssignableFrom <XmlAttributedTestEventX>(actual.Items[0]);
                        Assert.Equal(tex.Number, actualTex.Number);
                        Assert.Equal(tex.Text, actualTex.Text);
                        var actualTey = Assert.IsAssignableFrom <XmlAttributedTestEventY>(actual.Items[1]);
                        Assert.Equal(tey.Number, actualTey.Number);
                        Assert.Equal(tey.Flag, actualTey.Flag);
                    }
                }
        }
        public async Task <TData> Resolve <TData>(HttpResponse response, IDictionary <string, object> properties)
        {
            var content = await response.Content.ReadAsStringAsync();

            var _serializer = new XmlContentSerializer();

            return(_serializer.Deserialize <TData>(content));
        }
Exemplo n.º 3
0
        public void SutCanRoundTripAttributedClassInstance(
            XmlContentSerializer sut,
            XmlAttributedTestEventX xatex)
        {
            using (var ms = new MemoryStream())
                using (var w = XmlWriter.Create(ms))
                {
                    sut.Serialize(w, xatex);
                    w.Flush();
                    ms.Position = 0;
                    using (var r = XmlReader.Create(ms))
                    {
                        var content = sut.Deserialize(r);

                        var actual = Assert.IsAssignableFrom <XmlAttributedTestEventX>(content.Item);
                        Assert.Equal(xatex.Number, actual.Number);
                        Assert.Equal(xatex.Text, actual.Text);
                    }
                }
        }