/// <summary>
        /// Prepares a folder with files for the tests.
        /// </summary>
        /// <param name="skipNullContact">
        /// skips adding the null contact if True.
        /// </param>
        /// <returns>
        /// the path to the test folder
        /// </returns>
        private static string PrepareFolder(bool skipNullContact)
        {
            var folder = Path.Combine(Path.GetTempPath(), "BasicTests");

            if (Directory.Exists(folder))
            {
                Directory.Delete(folder, true);
            }

            Directory.CreateDirectory(folder);

            var file1 = new StringBuilder();

            file1.AppendLine("<?xml version=\"1.0\"?>");
            file1.AppendLine(
                "<ArrayOfStdContact xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");

            Contacts.AddContactWithoutPicture(file1);
            Contacts.AddContactWithPicture(file1);
            if (!skipNullContact)
            {
                Contacts.AddContactWithNulls(file1);
            }

            file1.Append("</ArrayOfStdContact>");

            File.WriteAllText(Path.Combine(folder, "file1"), file1.ToString());
            return(folder);
        }
Beispiel #2
0
        /// <summary>
        /// reads a full sample list of contacts
        /// </summary>
        /// <param name="clientFolderName">
        /// The client folder name.
        /// </param>
        /// <param name="result">
        /// The list of elements to be filled.
        /// </param>
        /// <returns>
        /// The result list of elements.
        /// </returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            var resultXml = new StringBuilder(102400);

            resultXml.AppendLine("<?xml version=\"1.0\"?>");
            resultXml.AppendLine(
                "<ArrayOfStdContact xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");

            Contacts.AddContactWithoutPicture(resultXml);
            Contacts.AddContactWithPicture(resultXml);
            Contacts.AddContactWithNulls(resultXml);

            resultXml.Append("</ArrayOfStdContact>");
            var textStream = new MemoryStream(Encoding.UTF8.GetBytes(result.ToString()));

            result = ((List <StdContact>)ContactListFormatter.Deserialize(textStream)).ToStdElements();
            CleanUpEntities(result);

            return(result);
        }