<commit_before>﻿using System.Xml.Linq;
using NUnit.Framework;
using Orchard.XmlRpc.Models;
using Orchard.XmlRpc.Services;

namespace Orchard.XmlRpc.Tests.Services {
    [TestFixture]
    public class XmlRpcWriterTests {
        [Test]
        public void MethodResponseWriterShouldSendParametersWithValues() {
            var mapper = new XmlRpcWriter();
            IMapper<XRpcMethodResponse, XElement> resposeMapper = mapper;

            var response = new XRpcMethodResponse();
            response.Params.Add(new XRpcData<int> { Value = 42 });
            var element = resposeMapper.Map(response);

            Assert.That(NoSpace(element.ToString()), Is.EqualTo("<methodResponse><params><param><value><int>42</int></value></param></params></methodResponse>"));
        }

        [Test]
        public void ArrayAndStructShouldWorkAsExpected() {
            var mapper = new XmlRpcWriter();
            IMapper<XRpcArray, XElement> arrayMapper = mapper;

            var arr = new XRpcArray();
            var structParam = XRpcData.For(new XRpcStruct());

            arr.Data.Add(structParam);
            arr.Data.Add(XRpcData.For(19));

            structParam.Value.Members.Add("Hello", XRpcData.For("world"));
            
            var element = arrayMapper.Map(arr);

            Assert.That(NoSpace(element.ToString()), Is.EqualTo(NoSpace(@"
<array>
<value><struct>
<members><member><name>Hello</name><value><string>world</string></value></member></members>
</struct></value>
<value><int>19</int></value>
</array>
")));
        }

        private static string NoSpace(string text) {
            return text.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
        }
    }
}<commit_msg>Fixing incorrect expectations about xmlrpc format in test<commit_after>﻿using System.Xml.Linq;
using NUnit.Framework;
using Orchard.XmlRpc.Models;
using Orchard.XmlRpc.Services;

namespace Orchard.XmlRpc.Tests.Services {
    [TestFixture]
    public class XmlRpcWriterTests {
        [Test]
        public void MethodResponseWriterShouldSendParametersWithValues() {
            var mapper = new XmlRpcWriter();
            IMapper<XRpcMethodResponse, XElement> resposeMapper = mapper;

            var response = new XRpcMethodResponse();
            response.Params.Add(new XRpcData<int> { Value = 42 });
            var element = resposeMapper.Map(response);

            Assert.That(NoSpace(element.ToString()), Is.EqualTo("<methodResponse><params><param><value><int>42</int></value></param></params></methodResponse>"));
        }

        [Test]
        public void ArrayAndStructShouldWorkAsExpected() {
            var mapper = new XmlRpcWriter();
            IMapper<XRpcArray, XElement> arrayMapper = mapper;

            var arr = new XRpcArray();
            var structParam = XRpcData.For(new XRpcStruct());

            arr.Data.Add(structParam);
            arr.Data.Add(XRpcData.For(19));

            structParam.Value.Members.Add("Hello", XRpcData.For("world"));
            
            var element = arrayMapper.Map(arr);

            Assert.That(NoSpace(element.ToString()), Is.EqualTo(NoSpace(@"
<array><data>
<value><struct>
<member><name>Hello</name><value><string>world</string></value></member>
</struct></value>
<value><int>19</int></value>
</data></array>
")));
        }

        private static string NoSpace(string text) {
            return text.Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
        }
    }
}
{'fraction_non_alphanumeric': 0.1511161991986262, 'fraction_numerical': 0.0045792787635947334, 'mean_word_length': 2.8491189427312777, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7394130', 'n_tokens_mistral': 1028, 'n_tokens_neox': 996, 'n_words': 175}