Ejemplo n.º 1
0
        public void CreateAccount()
        {
            //Test request
            string expected = File.ReadAllText(Path.Combine(_requestsTestDataPath, "CreateAccount.xml"));
            var    request  = new CreateAccount
            {
                SessionId         = "sid",
                DomainStr         = "testing.com",
                AccountProperties = new TPropertyValueList
                {
                    Items = new List <TPropertyValue>
                    {
                        new TPropertyValue
                        {
                            APIProperty = new TAPIProperty {
                                PropName = "u_name"
                            },
                            PropertyVal = new TPropertyString {
                                Val = "testing"
                            },
                            PropertyRight = TPermission.ReadWrite
                        },
                        new TPropertyValue
                        {
                            APIProperty = new TAPIProperty {
                                PropName = "u_alias"
                            },
                            PropertyVal = new TPropertyString {
                                Val = "tester"
                            },
                            PropertyRight = TPermission.ReadWrite
                        },
                        new TPropertyValue
                        {
                            APIProperty = new TAPIProperty {
                                PropName = "u_type"
                            },
                            PropertyVal = new TPropertyString {
                                Val = AccountType.User.ToString("d")
                            },
                            PropertyRight = TPermission.ReadWrite
                        }
                    }
                }
            };
            var requestXml = request.ToXml().InnerXmlFormatted();

            Assert.AreEqual(expected, requestXml);

            //Test response
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(File.ReadAllText(Path.Combine(_responsesTestDataPath, "CreateAccount.xml")));
            var response = request.FromHttpRequestResult(new HttpRequestResult {
                Response = doc.InnerXml
            });

            Assert.AreEqual("result", response.Type);
            Assert.True(response.Success);
        }