Exemple #1
0
        /// <summary>
        /// Generate a Sync Add command with body element.
        /// </summary>
        /// <returns>Returns a command list instance.</returns>
        private static object[] CreateSyncAddCommands()
        {
            Request.Body addBody = new Request.Body {
                Type = 1, Data = "Test sync add"
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType8> itemsElementName = new List <Request.ItemsChoiceType8>();

            items.Add(addBody);
            itemsElementName.Add(Request.ItemsChoiceType8.Body);

            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData
            {
                Items            = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };

            Request.SyncCollectionAdd syncAdd = new Request.SyncCollectionAdd
            {
                ClientId        = Guid.NewGuid().ToString("N"),
                ApplicationData = applicationData
            };

            List <object> commandList = new List <object> {
                syncAdd
            };

            return(commandList.ToArray());
        }
        /// <summary>
        /// Create a Request.Body instance.
        /// </summary>
        /// <param name="bodyType">the format type of the body content of the item</param>
        /// <param name="content">the data of the message body (2) or the message part of the calendar item, contact, document, e-mail, or task</param>
        /// <returns>The created Request.Body instance.</returns>
        internal static Request.Body CreateCalendarBody(byte bodyType, string content)
        {
            Request.Body calendarBody = new Request.Body
            {
                Type = bodyType,
                Data = content
            };

            return(calendarBody);
        }
        /// <summary>
        /// Create the elements of a note
        /// </summary>
        /// <returns>The dictionary of value and name for note's elements to be created</returns>
        protected Dictionary <Request.ItemsChoiceType8, object> CreateNoteElements()
        {
            Dictionary <Request.ItemsChoiceType8, object> addElements = new Dictionary <Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(this.Site, "subject");

            addElements.Add(Request.ItemsChoiceType8.Subject1, subject);

            Request.Body noteBody = new Request.Body {
                Type = 1, Data = "Content of the body."
            };
            addElements.Add(Request.ItemsChoiceType8.Body, noteBody);

            Request.Categories3 categories = new Request.Categories3 {
                Category = new string[] { "blue category" }
            };
            addElements.Add(Request.ItemsChoiceType8.Categories2, categories);

            addElements.Add(Request.ItemsChoiceType8.MessageClass, "IPM.StickyNote");
            return(addElements);
        }
Exemple #4
0
        /// <summary>
        /// Create the elements of a task.
        /// </summary>
        /// <returns>The dictionary of value and name for task's elements to be created.</returns>
        internal static Dictionary <Request.ItemsChoiceType8, object> CreateTaskElements()
        {
            Dictionary <Request.ItemsChoiceType8, object> addElements = new Dictionary <Request.ItemsChoiceType8, object>();

            Request.Body body = new Request.Body {
                Type = 1, Data = "Content of the body." + Guid.NewGuid().ToString()
            };
            addElements.Add(Request.ItemsChoiceType8.Body, body);

            DateTime startTime    = DateTime.Now.AddHours(1).AddDays(1);
            DateTime utcStartTime = startTime.ToUniversalTime();

            addElements.Add(Request.ItemsChoiceType8.UtcStartDate, utcStartTime);
            addElements.Add(Request.ItemsChoiceType8.StartDate, startTime);

            addElements.Add(Request.ItemsChoiceType8.UtcDueDate, utcStartTime.AddHours(5));
            addElements.Add(Request.ItemsChoiceType8.DueDate, startTime.AddHours(5));

            addElements.Add(Request.ItemsChoiceType8.ReminderSet, byte.Parse("1"));
            addElements.Add(Request.ItemsChoiceType8.ReminderTime, startTime.AddDays(-1));
            return(addElements);
        }
        /// <summary>
        /// Create a SyncCollectionAdd instance for adding a contact.
        /// </summary>
        /// <param name="fileAs">The FileAs element for the contact.</param>
        /// <param name="data">The body data of contact.</param>
        /// <param name="truncated">The Truncated element for the contact.</param>
        /// <returns>Return a SyncCollectionAdd instance.</returns>
        private static Request.SyncCollectionAdd CreateSyncAddContact(string fileAs, string data, bool? truncated)
        {
            Request.SyncCollectionAdd syncAdd = new Request.SyncCollectionAdd { ClientId = Guid.NewGuid().ToString("N") };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>();

            items.Add(fileAs);
            itemsElementName.Add(Request.ItemsChoiceType8.FileAs);

            Request.Body addBody = new Request.Body { Type = 1, Data = data };

            if (truncated != null)
            {
                addBody.TruncatedSpecified = true;
                addBody.Truncated = (bool)truncated;
            }

            items.Add(addBody);
            itemsElementName.Add(Request.ItemsChoiceType8.Body);

            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData
            {
                Items = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };
            syncAdd.ApplicationData = applicationData;

            return syncAdd;
        }
        /// <summary>
        /// Create the elements of a note
        /// </summary>
        /// <returns>The dictionary of value and name for note's elements to be created</returns>
        protected Dictionary<Request.ItemsChoiceType8, object> CreateNoteElements()
        {
            Dictionary<Request.ItemsChoiceType8, object> addElements = new Dictionary<Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(this.Site, "subject");
            addElements.Add(Request.ItemsChoiceType8.Subject1, subject);

            Request.Body noteBody = new Request.Body { Type = 1, Data = "Content of the body." };
            addElements.Add(Request.ItemsChoiceType8.Body, noteBody);

            Request.Categories3 categories = new Request.Categories3 { Category = new string[] { "blue category" } };
            addElements.Add(Request.ItemsChoiceType8.Categories2, categories);

            addElements.Add(Request.ItemsChoiceType8.MessageClass, "IPM.StickyNote");
            return addElements;
        }
        /// <summary>
        /// Create a Request.Body instance.
        /// </summary>
        /// <param name="bodyType">the format type of the body content of the item</param>
        /// <param name="content">the data of the message body (2) or the message part of the calendar item, contact, document, e-mail, or task</param>
        /// <returns>The created Request.Body instance.</returns>
        internal static Request.Body CreateCalendarBody(byte bodyType, string content)
        {
            Request.Body calendarBody = new Request.Body
            {
                Type = bodyType,
                Data = content
            };

            return calendarBody;
        }
        /// <summary>
        /// Create the elements of a task.
        /// </summary>
        /// <returns>The dictionary of value and name for task's elements to be created.</returns>
        internal static Dictionary<Request.ItemsChoiceType8, object> CreateTaskElements()
        {
            Dictionary<Request.ItemsChoiceType8, object> addElements = new Dictionary<Request.ItemsChoiceType8, object>();

            Request.Body body = new Request.Body { Type = 1, Data = "Content of the body." + Guid.NewGuid().ToString() };
            addElements.Add(Request.ItemsChoiceType8.Body, body);

            DateTime startTime = DateTime.Now.AddHours(1).AddDays(1);
            DateTime utcStartTime = startTime.ToUniversalTime();

            addElements.Add(Request.ItemsChoiceType8.UtcStartDate, utcStartTime);
            addElements.Add(Request.ItemsChoiceType8.StartDate, startTime);

            addElements.Add(Request.ItemsChoiceType8.UtcDueDate, utcStartTime.AddHours(5));
            addElements.Add(Request.ItemsChoiceType8.DueDate, startTime.AddHours(5));

            addElements.Add(Request.ItemsChoiceType8.ReminderSet, byte.Parse("1"));
            addElements.Add(Request.ItemsChoiceType8.ReminderTime, startTime.AddDays(-1));
            return addElements;
        }
        /// <summary>
        /// Generate a Sync Add command with body element.
        /// </summary>
        /// <returns>Returns a command list instance.</returns>
        private static object[] CreateSyncAddCommands()
        {
            Request.Body addBody = new Request.Body { Type = 1, Data = "Test sync add" };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType8> itemsElementName = new List<Request.ItemsChoiceType8>();

            items.Add(addBody);
            itemsElementName.Add(Request.ItemsChoiceType8.Body);

            Request.SyncCollectionAddApplicationData applicationData = new Request.SyncCollectionAddApplicationData
            {
                Items = items.ToArray(),
                ItemsElementName = itemsElementName.ToArray()
            };

            Request.SyncCollectionAdd syncAdd = new Request.SyncCollectionAdd
            {
                ClientId = Guid.NewGuid().ToString("N"),
                ApplicationData = applicationData
            };

            List<object> commandList = new List<object> { syncAdd };
            return commandList.ToArray();
        }
        /// <summary>
        /// This method is used to set value for contact properties.
        /// </summary>
        /// <param name="picture">The picture of the contact item.</param>
        /// <returns>The value for contact properties.</returns>
        protected Dictionary<Request.ItemsChoiceType8, object> SetContactProperties(string picture)
        {
            Request.Body contactBody = new Request.Body { Type = 1, Data = Common.GenerateResourceName(this.Site, "Body") };
            List<string> categories = new List<string> { this.Site.DefaultProtocolDocShortName + "Category" };
            Request.Categories1 contactCategories = new Request.Categories1 { Category = categories.ToArray() };
            List<string> children = new List<string> { Common.GenerateResourceName(this.Site, "Child") };
            Request.Children contactChildren = new Request.Children { Child = children.ToArray() };

            Dictionary<Request.ItemsChoiceType8, object> contactProperties = new Dictionary<Request.ItemsChoiceType8, object>
            {
                {
                    Request.ItemsChoiceType8.FileAs, Common.GenerateResourceName(this.Site, "Contact")
                },
                {
                    Request.ItemsChoiceType8.AccountName, "Contact1"
                },
                {
                    Request.ItemsChoiceType8.Anniversary, DateTime.Parse("2012-10-01")
                },
                {
                    Request.ItemsChoiceType8.AssistantName, "Assistant"
                },
                {
                    Request.ItemsChoiceType8.AssistantPhoneNumber, "54689733"
                },
                {
                    Request.ItemsChoiceType8.Birthday, DateTime.Parse("1980-04-12")
                },
                {
                    Request.ItemsChoiceType8.Body, contactBody
                },
                {
                    Request.ItemsChoiceType8.BusinessPhoneNumber, "987654321"
                },
                {
                    Request.ItemsChoiceType8.Business2PhoneNumber, "123456789"
                },
                {
                    Request.ItemsChoiceType8.BusinessAddressCity, "Beijing"
                },
                {
                    Request.ItemsChoiceType8.BusinessAddressCountry, "China"
                },
                {
                    Request.ItemsChoiceType8.BusinessAddressPostalCode, "100080"
                },
                {
                    Request.ItemsChoiceType8.BusinessAddressState, "Haidian"
                },
                {
                    Request.ItemsChoiceType8.BusinessAddressStreet, "Danling"
                },
                {
                    Request.ItemsChoiceType8.BusinessFaxNumber, "0123456"
                },
                {
                    Request.ItemsChoiceType8.CarPhoneNumber, "123456789"
                },
                {
                    Request.ItemsChoiceType8.Categories1, contactCategories
                },
                {
                    Request.ItemsChoiceType8.Children, contactChildren
                },
                {
                    Request.ItemsChoiceType8.CompanyMainPhone, "23456987"
                },
                {
                    Request.ItemsChoiceType8.CompanyName, "Microsoft"
                },
                {
                    Request.ItemsChoiceType8.CustomerId, "Customer1"
                },
                {
                    Request.ItemsChoiceType8.Department, "Testing"
                },

                // Domain name "contoso.com" is just a sample domain name. It does not have any relationship to the domain name configured in common ptfconfig file.
                {
                    Request.ItemsChoiceType8.Email1Address, "*****@*****.**"
                },
                {
                    Request.ItemsChoiceType8.Email2Address, "*****@*****.**"
                },
                {
                    Request.ItemsChoiceType8.Email3Address, "*****@*****.**"
                },
                {
                    Request.ItemsChoiceType8.FirstName, "Aaron"
                },
                {
                    Request.ItemsChoiceType8.GovernmentId, "99910819810809502X"
                },
                {
                    Request.ItemsChoiceType8.Home2PhoneNumber, "1234568742"
                },
                {
                    Request.ItemsChoiceType8.HomeAddressCity, "Princeton"
                },
                {
                    Request.ItemsChoiceType8.HomeAddressCountry, "United States"
                },
                {
                    Request.ItemsChoiceType8.HomeAddressPostalCode, "08989"
                },
                {
                    Request.ItemsChoiceType8.HomeAddressState, "New Jersey"
                },
                {
                    Request.ItemsChoiceType8.HomeAddressStreet, "Nassauy"
                },
                {
                    Request.ItemsChoiceType8.HomeFaxNumber, "012345678"
                },
                {
                    Request.ItemsChoiceType8.HomePhoneNumber, "014578932"
                },
                {
                    Request.ItemsChoiceType8.IMAddress, "InstantIMAddress"
                },
                {
                    Request.ItemsChoiceType8.IMAddress2, "AlternativeIMAddress"
                },
                {
                    Request.ItemsChoiceType8.IMAddress3, "TertiaryIMAddress"
                },
                {
                    Request.ItemsChoiceType8.JobTitle, "Tester"
                },
                {
                    Request.ItemsChoiceType8.LastName, "Clinton"
                },
                {
                    Request.ItemsChoiceType8.ManagerName, "Jodge"
                },
                {
                    Request.ItemsChoiceType8.MiddleName, "Jafferson"
                },
                {
                    Request.ItemsChoiceType8.MMS, "mms://enmms.chinabroadcast.cn"
                },
                {
                    Request.ItemsChoiceType8.MobilePhoneNumber, "12345678932"
                },
                {
                    Request.ItemsChoiceType8.NickName, "Ara"
                },
                {
                    Request.ItemsChoiceType8.OfficeLocation, "Beijing"
                },
                {
                    Request.ItemsChoiceType8.OtherAddressCity, "Toronto"
                },
                {
                    Request.ItemsChoiceType8.OtherAddressCountry, "Canada"
                },
                {
                    Request.ItemsChoiceType8.OtherAddressPostalCode, "K1N5H3"
                },
                {
                    Request.ItemsChoiceType8.OtherAddressState, "Ontario"
                },
                {
                    Request.ItemsChoiceType8.OtherAddressStreet, "Avenue"
                },
                {
                    Request.ItemsChoiceType8.PagerNumber, "1"
                },
                {
                    Request.ItemsChoiceType8.RadioPhoneNumber, "1234562589"
                },
                {
                    Request.ItemsChoiceType8.Spouse, "Emily"
                },
                {
                    Request.ItemsChoiceType8.Suffix, "CL."
                },
                {
                    Request.ItemsChoiceType8.Title, "Test"
                },
                {
                    Request.ItemsChoiceType8.WebPage, "http://Test.html"
                },
                {
                    Request.ItemsChoiceType8.YomiCompanyName, "Sony"
                },
                {
                    Request.ItemsChoiceType8.YomiFirstName, "Hanasaki"
                },
                {
                    Request.ItemsChoiceType8.YomiLastName, "Tsuki"
                }
            };

            if (picture != null)
            {
                contactProperties.Add(Request.ItemsChoiceType8.Picture, Convert.ToBase64String(File.ReadAllBytes(picture)));
            }

            return contactProperties;
        }
        public void MSASCMD_S19_TC50_Sync_Class()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Class element is not supported in a Sync command response when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Add a new Note item
            string noteSubject = Common.GenerateResourceName(Site, "noteSubject");
            Request.Body noteBody = new Request.Body { Type = 1, Data = "Content of the body." };
            Request.Categories3 categories = new Request.Categories3 { Category = new string[] { "blue category" } };

            Request.SyncCollectionAdd noteData = new Request.SyncCollectionAdd
            {
                ClientId = TestSuiteBase.ClientId,
                ApplicationData = new Request.SyncCollectionAddApplicationData
                {
                    ItemsElementName =
                        new Request.ItemsChoiceType8[]
                        {
                            Request.ItemsChoiceType8.Subject1, 
                            Request.ItemsChoiceType8.Body,
                            Request.ItemsChoiceType8.Categories2, 
                            Request.ItemsChoiceType8.MessageClass
                        },
                    Items =
                        new object[]
                        {
                            noteSubject, 
                            noteBody, 
                            categories,
                            "IPM.StickyNote"
                        }
                },
                Class = "Calendar"
            };

            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.NotesCollectionId));

            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.NotesCollectionId, noteData);
            SyncResponse syncResponse = this.Sync(syncRequest, false);

            Response.SyncCollectionsCollectionResponses responses = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            #endregion

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R941");

            // Verify MS-ASCMD requirement: MS-ASCMD_R941
            Site.CaptureRequirementIfAreEqual<string>(
                "Calendar",
                responses.Add[0].Class,
                941,
                @"[In Class(Sync)] As a child element of the Add element in the Sync command response, the Class element<20> identifies the class of the item being added to the collection.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_9945");

            // Verify MS-ASCMD requirement: MS-ASCMD_R9945
            Site.CaptureRequirementIfAreEqual<string>(
                "Calendar",
                responses.Add[0].Class,
                9945,
                @"[In Class(Sync)] In all contexts of a Sync command request or Sync command response, the valid Class element value is Calendar.");
        }