コード例 #1
0
        /// <summary>
        /// Call sync command to update properties of an existing calendar item.
        /// </summary>
        /// <param name="serverId">Server Id of the calendar item.</param>
        /// <param name="collectionId">Collection Id of the folder that calendar item is contained in.</param>
        /// <param name="syncKey">Sync key value.</param>
        /// <param name="items">The dictionary store calendar item's element name and element value, which will be changed.</param>
        /// <returns>Return Sync Change response.</returns>
        public SyncStore UpdateCalendarProperty(string serverId, string collectionId, string syncKey, Dictionary <Request.ItemsChoiceType7, object> items)
        {
            Request.SyncCollectionChangeApplicationData syncChangeData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = items.Keys.ToArray <Request.ItemsChoiceType7>(),
                Items            = items.Values.ToArray <object>()
            };

            Request.SyncCollectionChange syncChange = new Request.SyncCollectionChange
            {
                ApplicationData = syncChangeData,
                ServerId        = serverId
            };

            SyncRequest syncChangeRequest = new SyncRequest
            {
                RequestData = new Request.Sync {
                    Collections = new Request.SyncCollection[1]
                }
            };

            syncChangeRequest.RequestData.Collections[0] = new Request.SyncCollection
            {
                Commands     = new object[] { syncChange },
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            SyncStore syncChanageResponse = this.CALAdapter.Sync(syncChangeRequest);

            return(syncChanageResponse);
        }
コード例 #2
0
        /// <summary>
        /// Call sync command to update properties of an existing calendar item.
        /// </summary>
        /// <param name="serverId">Server Id of the calendar item.</param>
        /// <param name="collectionId">Collection Id of the folder that calendar item is contained in.</param>
        /// <param name="syncKey">Sync key value.</param>
        /// <param name="items">The dictionary store calendar item's element name and element value, which will be changed.</param>
        /// <returns>Return Sync Change response.</returns>
        public SyncStore UpdateCalendarProperty(string serverId, string collectionId, string syncKey, Dictionary<Request.ItemsChoiceType7, object> items)
        {
            Request.SyncCollectionChangeApplicationData syncChangeData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = items.Keys.ToArray<Request.ItemsChoiceType7>(),
                Items = items.Values.ToArray<object>()
            };

            Request.SyncCollectionChange syncChange = new Request.SyncCollectionChange
            {
                ApplicationData = syncChangeData,
                ServerId = serverId
            };

            SyncRequest syncChangeRequest = new SyncRequest
            {
                RequestData = new Request.Sync { Collections = new Request.SyncCollection[1] }
            };

            syncChangeRequest.RequestData.Collections[0] = new Request.SyncCollection
            {
                Commands = new object[] { syncChange },
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            SyncStore syncChanageResponse = this.CALAdapter.Sync(syncChangeRequest);
            return syncChanageResponse;
        }
コード例 #3
0
        public void MSASCMD_S19_TC27_Sync_Change()
        {
            Site.Assume.AreEqual<string>("Base64", Common.GetConfigurationPropertyValue("HeaderEncodingType", this.Site), "The device ID should be same across all requests, when the HeaderEncodingType is PlainText.");
            CMDAdapter.ChangeDeviceID(Common.GetConfigurationPropertyValue("DeviceID", this.Site));
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId));

            #region Add a new contact with Sync operation.
            string contactFileAS = Common.GenerateResourceName(Site, "FileAS");
            Request.SyncCollectionAdd addData = this.CreateAddContactCommand("FirstName", "MiddleName", "LastName", contactFileAS, null);

            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.ContactsCollectionId, addData);
            SyncResponse syncResponse = this.Sync(syncRequest, false);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            Response.SyncCollectionsCollectionResponses collectionResponse = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.IsNotNull(collectionResponse, "The responses element should exist in the Sync response.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5255
            Site.CaptureRequirementIfIsNotNull(
                collectionResponse.Add,
                5255,
                @"[In Responses] Element Responses in Sync command response (section 2.2.2.19), the child elements is Add (section 2.2.3.7.2)[, Fetch (section 2.2.3.63.2) ](If the operation succeeded.)");

            Site.Assert.AreEqual<int>(1, int.Parse(collectionResponse.Add[0].Status), "The new contact should be added correctly.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, contactFileAS);
            this.FolderSync();
            #endregion

            #region Change DeviceID and synchronize the changes in the Contacts folder.
            string syncKey = this.LastSyncKey;
            CMDAdapter.ChangeDeviceID("Device2");
            this.RecordDeviceInfoChanged();

            this.GetInitialSyncResponse(this.User1Information.ContactsCollectionId);
            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            string serverId = TestSuiteBase.FindServerId(syncResponse, "FileAs", contactFileAS);
            Site.Assert.IsNotNull(serverId, "The added contact should be synchronized down to the current device.");
            #endregion

            #region Change the added Contact information and then synchronize the change to the server.
            string updatedContactFileAS = Common.GenerateResourceName(Site, "UpdatedFileAS");
            Request.SyncCollectionChange appDataChange = CreateChangedContact(serverId, new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.FileAs }, new object[] { updatedContactFileAS });
            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.ContactsCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The status code of Sync change operation should be 1.");
            #endregion

            #region Restore DeviceID and synchronize the changes in the Contacts folder.
            
            CMDAdapter.ChangeDeviceID(Common.GetConfigurationPropertyValue("DeviceID", this.Site));

            syncRequest = TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId);
            syncRequest.RequestData.Collections[0].SyncKey = syncKey;
            syncRequest.RequestData.Collections[0].GetChanges = true;
            syncRequest.RequestData.Collections[0].GetChangesSpecified = true;
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The Sync command should be conducted successfully.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, updatedContactFileAS);

            Response.SyncCollectionsCollectionCommands syncCollectionCommands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(syncCollectionCommands, "The commands element should exist in the Sync response.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3119
            Site.CaptureRequirementIfIsNotNull(
                syncCollectionCommands.Change,
                3119,
                @"[In GetChanges] If there have been changes since the last synchronization, the server response includes a Commands element (section 2.2.3.32) that contains additions, deletions, and changes.");

            Site.Assert.IsTrue(((Response.SyncCollections)syncResponse.ResponseData.Item).Collection.Length >= 1, "The length of Collections element should not less than 1. The actual value is {0}.", ((Response.SyncCollections)syncResponse.ResponseData.Item).Collection.Length);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4602
            // If the Assert statement above is passed, the requirement is captured.
            Site.CaptureRequirement(
                4602,
                @"[In SyncKey(Sync)] If the synchronization is successful, the server responds by sending all objects in the collection.");

            List<string> elements = new List<string>
            {
                Request.ItemsChoiceType4.FirstName.ToString(),
                Request.ItemsChoiceType4.MiddleName.ToString(),
                Request.ItemsChoiceType4.LastName.ToString()
            };

            Response.SyncCollectionsCollectionCommands commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands, "The Commands element should not be null.");
            Site.Assert.IsNotNull(commands.Change, "The Change element should not be null.");
            Site.Assert.IsTrue(commands.Change.Length > 0, "The Change element should have one sub-element at least.");
            Site.Assert.IsNotNull(commands.Change[0].ApplicationData, "The ApplicationData element of the first Change element should not be null.");
            Site.Assert.IsNotNull(commands.Change[0].ApplicationData.ItemsElementName, "The ItemsElementName element of the ApplicationData element of the first Change element should not be null.");
            Site.Assert.IsTrue(commands.Change[0].ApplicationData.ItemsElementName.Length > 0, "The ItemsElementName element of the ApplicationData element of the first Change element should have one sub-element at least.");

            bool isVerifyR879 = false;
            foreach (Response.ItemsChoiceType7 itemElementName in commands.Change[0].ApplicationData.ItemsElementName)
            {
                if (elements.Contains(itemElementName.ToString()))
                {
                    isVerifyR879 = true;
                    break;
                }
            }

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R879
            Site.CaptureRequirementIfIsFalse(
                isVerifyR879,
                879,
                @"[In Change] In all other cases, if an in-schema property is not specified in a change request, the property is actively deleted from the item on the server.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R881
            Site.CaptureRequirementIfIsFalse(
                isVerifyR879,
                881,
                @"[In Change] Otherwise [if a client dose not be aware of this [if an in-schema property is not specified in a change request, the property is actively deleted from the item on the server] when it [client] is sending Sync requests], data can be unintentionally removed.");
            #endregion

            #region Send a MIME-formatted e-mail from user1 to user2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);

            this.SwitchUser(this.User2Information);
            serverId = TestSuiteBase.FindServerId(this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null), "Subject", emailSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Call Sync command to set a flag to an email.
            string updatedEmailSubject = Common.GenerateResourceName(Site, "updatedSubject");

            DateTime startDate = DateTime.Now.AddDays(5.0);
            DateTime dueDate = startDate.AddHours(1.0);

            // Define email flag
            Request.Flag emailFlag = new Request.Flag
            {
                StartDate = startDate,
                StartDateSpecified = true,
                DueDate = dueDate,
                DueDateSpecified = true
            };

            Request.SyncCollectionChangeApplicationData applicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Flag, Request.ItemsChoiceType7.Subject },
                Items = new object[] { emailFlag, updatedEmailSubject }
            };

            appDataChange = new Request.SyncCollectionChange { ApplicationData = applicationData, ServerId = serverId };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R875
            Site.CaptureRequirementIfAreEqual<uint>(
                1,
                Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)),
                875,
                @"[In Change] If all the other elements are sent, extra bandwidth is used, but no errors occur.");

            // Define updated email flag
            Request.Flag updatedEmailFlag = new Request.Flag
            {
                StartDate = startDate,
                StartDateSpecified = true,
                DueDate = dueDate,
                DueDateSpecified = true
            };

            applicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Flag },
                Items = new object[] { updatedEmailFlag }
            };

            appDataChange = new Request.SyncCollectionChange { ApplicationData = applicationData, ServerId = serverId };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The email should be updated successfully.");

            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R873
            bool isVerifyR873 = !string.IsNullOrEmpty(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject));
            Site.CaptureRequirementIfIsTrue(
                isVerifyR873,
                873,
                @"[In Change] Certain in-schema properties remain untouched in the following three cases: If there is only an email:Flag ([MS-ASEMAIL] section 2.2.2.27) [, email:Read ([MS-ASEMAIL] section 2.2.2.47), or email:Categories ([MS-ASEMAIL] section 2.2.2.9)] change (that is, if only an email:Flag, email:Categories or email:Read element is present), all other properties will remain unchanged.");
            #endregion

            #region Send a MIME-formatted e-mail from user1 to user2.
            this.SwitchUser(this.User1Information);
            emailSubject = Common.GenerateResourceName(this.Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);

            this.SwitchUser(this.User2Information);
            serverId = TestSuiteBase.FindServerId(this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null), "Subject", emailSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Call Sync command to set a Read element to an email.
            applicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Read, Request.ItemsChoiceType7.Subject },
                Items = new object[] { true, updatedEmailSubject }
            };

            appDataChange = new Request.SyncCollectionChange { ApplicationData = applicationData, ServerId = serverId };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The email should be updated successfully.");

            applicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Read },
                Items = new object[] { true }
            };

            appDataChange = new Request.SyncCollectionChange { ApplicationData = applicationData, ServerId = serverId };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The email should be updated successfully.");

            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5825
            bool isVerifyR5825 = !string.IsNullOrEmpty(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject));
            Site.CaptureRequirementIfIsTrue(
                isVerifyR5825,
                5825,
                @"[In Change] Certain in-schema properties remain untouched in the following three cases: If there is only an [email:Flag ([MS-ASEMAIL] section 2.2.2.27),] email:Read ([MS-ASEMAIL] section 2.2.2.47) [, or email:Categories ([MS-ASEMAIL] section 2.2.2.9)] change (that is, if only an email:Flag, email:Categories or email:Read element is present), all other properties will remain unchanged.");
            #endregion

            #region Send a MIME-formatted e-mail from user1 to user2.
            this.SwitchUser(this.User1Information);
            emailSubject = Common.GenerateResourceName(this.Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);

            this.SwitchUser(this.User2Information);
            serverId = TestSuiteBase.FindServerId(this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, null), "Subject", emailSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Call Sync command to set a Categories element to an email.
            Request.Categories categories = new Request.Categories { Category = new string[] { "company" } };

            applicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Categories, Request.ItemsChoiceType7.Subject },
                Items = new object[] { categories, updatedEmailSubject }
            };

            appDataChange = new Request.SyncCollectionChange { ApplicationData = applicationData, ServerId = serverId };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The email should be updated successfully.");

            applicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Categories },
                Items = new object[] { categories }
            };

            appDataChange = new Request.SyncCollectionChange { ApplicationData = applicationData, ServerId = serverId };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The email should be updated successfully.");

            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5826
            bool isVerifyR5826 = !string.IsNullOrEmpty(TestSuiteBase.FindServerId(syncResponse, "Subject", emailSubject));
            Site.CaptureRequirementIfIsTrue(
                isVerifyR5826,
                5826,
                @"[In Change] Certain in-schema properties remain untouched in the following three cases: If there is only [an email:Flag ([MS-ASEMAIL] section 2.2.2.27), email:Read ([MS-ASEMAIL] section 2.2.2.47), or] email:Categories ([MS-ASEMAIL] section 2.2.2.9) change (that is, if only an email:Flag, email:Categories or email:Read element is present), all other properties will remain unchanged.");
            #endregion

            #region Call Sync Add operation to add a new contact.
            this.SwitchUser(this.User1Information);
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(this.User1Information.ContactsCollectionId));

            string contactFileAs = Common.GenerateResourceName(Site, "FileAS");

            addData.ClientId = TestSuiteBase.ClientId;
            addData.ApplicationData = new Request.SyncCollectionAddApplicationData
            {
                ItemsElementName =
                    new Request.ItemsChoiceType8[]
                    {
                        Request.ItemsChoiceType8.FileAs, Request.ItemsChoiceType8.FirstName,
                        Request.ItemsChoiceType8.MiddleName, Request.ItemsChoiceType8.LastName,
                        Request.ItemsChoiceType8.Picture
                    },
                Items =
                    new object[]
                    {
                        contactFileAs, "FirstName", "MiddleName", "LastName",
                        Convert.ToBase64String(File.ReadAllBytes("number1.jpg"))
                    }
            };

            if ("12.1" != Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site))
            {
                addData.Class = "Contacts";
            }

            syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.ContactsCollectionId, addData);
            syncResponse = this.Sync(syncRequest, false);

            collectionResponse = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.IsNotNull(collectionResponse, "The responses element should exist in the Sync response.");
            Site.Assert.AreEqual<int>(1, int.Parse(collectionResponse.Add[0].Status), "The new contact should be added successfully.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, contactFileAs);

            syncResponse = this.SyncChanges(this.User1Information.ContactsCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            serverId = TestSuiteBase.FindServerId(syncResponse, "FileAs", contactFileAs);
            Site.Assert.IsNotNull(serverId, "The added contact should be synchronized down to the current device.");

            Response.SyncCollectionsCollectionCommandsAddApplicationData responseApplicationData = TestSuiteBase.GetAddApplicationData(syncResponse, Response.ItemsChoiceType8.FileAs, contactFileAS);
            Site.Assert.IsNotNull(responseApplicationData, "The ApplicationData of the calendar should not be null.");

            Response.Body body = null;
            for (int i = 0; i < responseApplicationData.ItemsElementName.Length; i++)
            {
                if (responseApplicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Body)
                {
                    body = responseApplicationData.Items[i] as Response.Body;
                    break;
                }
            }

            Site.Assert.IsNotNull(body, "The Body element should be in the ApplicationData of the contact item.");
            string originalPicture = (string)TestSuiteBase.GetElementValueFromSyncResponse(syncResponse, serverId, Response.ItemsChoiceType8.Picture);
            Site.Assert.IsNotNull(originalPicture, "The picture of the contact should exist.");
            #endregion

            #region Call Sync change operation to update the FileAs element of the contact.
            string updatedContactFileAs = Common.GenerateResourceName(Site, "updatedContactFileAs");

            Request.SyncCollectionChangeApplicationData changeApplicationData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.FileAs },
                Items = new object[] { updatedContactFileAs }
            };

            appDataChange = new Request.SyncCollectionChange
            {
                ApplicationData = changeApplicationData,
                ServerId = serverId
            };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.ContactsCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The FileAs of the contact should be updated successfully.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, contactFileAs);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.ContactsCollectionId, updatedContactFileAs);

            syncResponse = this.SyncChanges(this.User1Information.ContactsCollectionId);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");

            responseApplicationData = TestSuiteBase.GetAddApplicationData(syncResponse, Response.ItemsChoiceType8.FileAs, updatedContactFileAs);
            Site.Assert.IsNotNull(responseApplicationData, "The ApplicationData of the updated contact should not be null.");

            Response.Body currentBody = null;
            for (int i = 0; i < responseApplicationData.ItemsElementName.Length; i++)
            {
                if (responseApplicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Body)
                {
                    currentBody = responseApplicationData.Items[i] as Response.Body;
                    break;
                }
            }

            Site.Assert.IsNotNull(currentBody, "The Body element should be in the ApplicationData of the updated contact item.");
            string currentPicture = (string)TestSuiteBase.GetElementValueFromSyncResponse(syncResponse, serverId, Response.ItemsChoiceType8.Picture);
            Site.Assert.IsNotNull(currentPicture, "The picture of the updated contact should exist.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R878
            bool isVerifyR878 = body.Type == currentBody.Type && body.EstimatedDataSize == currentBody.EstimatedDataSize && originalPicture == currentPicture;
            Site.CaptureRequirementIfIsTrue(
                isVerifyR878,
                878,
                @"[In Change] [Certain in-schema properties remain untouched in the following three cases:] If the airsyncbase:Body, airsyncbase:Data, or contacts:Picture elements are not present, the corresponding properties will remain unchanged.");
            #endregion
        }
コード例 #4
0
        public void MSASCMD_S19_TC51_Sync_Change_Exceptions()
        {
            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.");
            Site.Assume.AreNotEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Recurrences cannot be added in protocol version 16.0");

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

            #region Call Sync Add operation to add a new recurrence calendar.
            string recurrenceCalendarSubject = Common.GenerateResourceName(Site, "calendarSubject");
            string location = Common.GenerateResourceName(Site, "Room");
            DateTime currentDate = DateTime.Now.AddDays(1);
            DateTime startTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 10, 0, 0);
            DateTime endTime = startTime.AddHours(10);

            Request.ExceptionsException exception = new Request.ExceptionsException();
            exception.ExceptionStartTime = startTime.AddDays(2).ToString("yyyyMMddTHHmmssZ");
            Request.Exceptions exceptions = new Request.Exceptions() { Exception = new Request.ExceptionsException[] { exception } };

            Request.Recurrence recurrence = new Request.Recurrence
            {
                Type = 0
            };

            Request.SyncCollectionAdd recurrenceCalendarData = new Request.SyncCollectionAdd
            {
                ClientId = TestSuiteBase.ClientId,
                ApplicationData =
                    new Request.SyncCollectionAddApplicationData
                    {
                        ItemsElementName =
                            new Request.ItemsChoiceType8[] 
                            { 
                                Request.ItemsChoiceType8.Subject, Request.ItemsChoiceType8.Location,
                                Request.ItemsChoiceType8.StartTime, Request.ItemsChoiceType8.EndTime,
                                Request.ItemsChoiceType8.Recurrence, Request.ItemsChoiceType8.Exceptions,
                                Request.ItemsChoiceType8.UID
                            },
                        Items =
                        new object[] 
                        { 
                            recurrenceCalendarSubject, location, 
                            startTime.ToString("yyyyMMddTHHmmssZ"),
                            endTime.ToString("yyyyMMddTHHmmssZ"),
                            recurrence, exceptions, Guid.NewGuid().ToString()
                        }
                    },
                Class = "Calendar"
            };

            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, recurrenceCalendarData);
            SyncResponse syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            Response.SyncCollectionsCollectionResponses responses = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.AreEqual<int>(1, int.Parse(responses.Add[0].Status), "The calendar should be added successfully.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, recurrenceCalendarSubject);

            syncResponse = this.SyncChanges(this.User1Information.CalendarCollectionId);
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", recurrenceCalendarSubject);
            Site.Assert.IsNotNull(serverId, "The recurrence calendar should be found.");
            #endregion

            #region Change the subject of the added recurrence calendar.
            string updatedCalendarSubject = Common.GenerateResourceName(Site, "updatedCalendarSubject");

            Request.SyncCollectionChangeApplicationData changeCalednarData = new Request.SyncCollectionChangeApplicationData();
            changeCalednarData.ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Subject, Request.ItemsChoiceType7.Recurrence };
            changeCalednarData.Items = new object[] { updatedCalendarSubject, recurrence };

            Request.SyncCollectionChange appDataChange = new Request.SyncCollectionChange
            {
                ApplicationData = changeCalednarData,
                ServerId = serverId
            };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The FileAs of the contact should be updated successfully.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, recurrenceCalendarSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, updatedCalendarSubject);

            syncResponse = this.SyncChanges(this.User1Information.CalendarCollectionId);
            serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", updatedCalendarSubject);
            Site.Assert.IsNotNull(serverId, "The recurrence calendar should be found.");

            Response.SyncCollectionsCollectionCommands commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands.Add, "The Add element should not be null.");

            foreach (Response.SyncCollectionsCollectionCommandsAdd item in commands.Add)
            {
                if (item.ServerId == serverId)
                {
                    for (int i = 0; i < item.ApplicationData.ItemsElementName.Length; i++)
                    {
                        if (item.ApplicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Exceptions)
                        {
                            Response.Exceptions currentExceptions = item.ApplicationData.Items[i] as Response.Exceptions;
                            Site.Assert.IsNotNull(currentExceptions, "The Exceptions element should exist.");

                            Response.ExceptionsException currentException = currentExceptions.Exception[0];

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

                            // Verify MS-ASCMD requirement: MS-ASCMD_R877
                            Site.CaptureRequirementIfAreEqual<string>(
                                exception.ExceptionStartTime.ToString(),
                                currentException.ExceptionStartTime.ToString(),
                                877,
                                @"[In Change] If a calendar:Exception ([MS-ASCAL] section 2.2.2.19) node within the calendar:Exceptions node is not present, that particular exception will remain unchanged.");

                            break;
                        }
                    }

                    break;
                }
            }
            #endregion

            #region Change the subject of the added recurrence calendar again.
            string allNewCalendarSubject = Common.GenerateResourceName(Site, "updatedCalendarSubject");

            changeCalednarData.ItemsElementName = new Request.ItemsChoiceType7[] { Request.ItemsChoiceType7.Subject, Request.ItemsChoiceType7.Recurrence, Request.ItemsChoiceType7.Exceptions, Request.ItemsChoiceType7.UID };
            changeCalednarData.Items = new object[] { allNewCalendarSubject, recurrence, null, Guid.NewGuid().ToString() };

            appDataChange = new Request.SyncCollectionChange
            {
                ApplicationData = changeCalednarData,
                ServerId = serverId
            };

            syncRequest = CreateSyncChangeRequest(this.LastSyncKey, this.User1Information.CalendarCollectionId, appDataChange);
            syncResponse = this.Sync(syncRequest);
            Site.Assert.AreEqual<uint>(1, Convert.ToUInt32(TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Status)), "The FileAs of the contact should be updated successfully.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, updatedCalendarSubject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.CalendarCollectionId, allNewCalendarSubject);

            syncResponse = this.SyncChanges(this.User1Information.CalendarCollectionId);
            serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", allNewCalendarSubject);
            Site.Assert.IsNotNull(serverId, "The recurrence calendar should be found.");

            commands = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Commands) as Response.SyncCollectionsCollectionCommands;
            Site.Assert.IsNotNull(commands.Add, "The Add element should not be null.");

            foreach (Response.SyncCollectionsCollectionCommandsAdd item in commands.Add)
            {
                if (item.ServerId == serverId)
                {
                    for (int i = 0; i < item.ApplicationData.ItemsElementName.Length; i++)
                    {
                        if (item.ApplicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Exceptions)
                        {
                            Response.Exceptions currentExceptions = item.ApplicationData.Items[i] as Response.Exceptions;
                            Site.Assert.IsNotNull(currentExceptions, "The Exceptions element should exist.");

                            Response.ExceptionsException currentException = currentExceptions.Exception[0];

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

                            // Verify MS-ASCMD requirement: MS-ASCMD_R876
                            Site.CaptureRequirementIfAreEqual<string>(
                                exception.ExceptionStartTime.ToString(),
                                currentException.ExceptionStartTime.ToString(),
                                876,
                                @"[In Change] [Certain in-schema properties remain untouched in the following three cases:] If a calendar:Exceptions ([MS-ASCAL] section 2.2.2.20) node is not specified, the properties for that calendar:Exceptions node will remain unchanged.");

                            break;
                        }
                    }

                    break;
                }
            }
            #endregion
        }
コード例 #5
0
        public void MSASCAL_S01_TC33_DeletePropertyOfException()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(2242, this.Site), "Exchange 2007 does not support deleting elements of a recurring calendar item in an Exception element.");
            Site.Assume.AreNotEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The recurring calendar item cannot be created when protocol version is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call Sync command to add a calendar to the server, and sync calendars from the server.

            Dictionary<Request.ItemsChoiceType8, object> calendarItem = new Dictionary<Request.ItemsChoiceType8, object>();

            DateTime exceptionStartTime = this.StartTime.AddDays(3);

            // Set Calendar StartTime, EndTime elements
            calendarItem.Add(Request.ItemsChoiceType8.StartTime, this.StartTime.ToString("yyyyMMddTHHmmssZ"));
            calendarItem.Add(Request.ItemsChoiceType8.EndTime, this.EndTime.ToString("yyyyMMddTHHmmssZ"));

            // Set Calendar Recurrence element including Occurrence sub-element
            byte recurrenceType = byte.Parse("0");
            Request.Recurrence recurrence = this.CreateCalendarRecurrence(recurrenceType, 6, 1);

            // Set Calendar Exceptions element
            Request.Exceptions exceptions = new Request.Exceptions { Exception = new Request.ExceptionsException[] { } };
            List<Request.ExceptionsException> exceptionList = new List<Request.ExceptionsException>();

            // Set ExceptionStartTime element in exception
            Request.ExceptionsException exception = TestSuiteHelper.CreateExceptionRequired(exceptionStartTime.ToString("yyyyMMddTHHmmssZ"));

            exception.Subject = "Calendar Exception";
            exception.Location = "Room 666";
            exceptionList.Add(exception);
            exceptions.Exception = exceptionList.ToArray();

            calendarItem.Add(Request.ItemsChoiceType8.Recurrence, recurrence);
            calendarItem.Add(Request.ItemsChoiceType8.Exceptions, exceptions);
            calendarItem.Add(Request.ItemsChoiceType8.Location, this.Location);

            string emailAddress = Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain);
            calendarItem.Add(Request.ItemsChoiceType8.Attendees, TestSuiteHelper.CreateAttendeesRequired(new string[] { emailAddress }, new string[] { this.User2Information.UserName }));
            calendarItem.Add(Request.ItemsChoiceType8.MeetingStatus, (byte)1);
            if (!this.IsActiveSyncProtocolVersion121)
            {
                calendarItem.Add(Request.ItemsChoiceType8.ResponseRequested, true);
                calendarItem.Add(Request.ItemsChoiceType8.DisallowNewTimeProposal, true);
            }

            string subject = Common.GenerateResourceName(Site, "subject");
            calendarItem.Add(Request.ItemsChoiceType8.Subject, subject);

            this.AddSyncCalendar(calendarItem);

            SyncItem calendar = this.GetChangeItem(this.User1Information.CalendarCollectionId, subject);

            Site.Assert.IsNotNull(calendar.Calendar, "The calendar with subject {0} should exist in server.", subject);
            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.CalendarCollectionId, subject);
            #endregion

            #region Call Sync command to delete the Location property of the exception to change the calendar, and sync calendars from the server.

            SyncStore syncResponse1 = this.InitializeSync(this.User1Information.CalendarCollectionId, null);
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(this.User1Information.CalendarCollectionId, syncResponse1.SyncKey, true);
            SyncStore syncResponse2 = this.CALAdapter.Sync(syncRequest);

            // Delete Location property of the Exception
            Dictionary<Request.ItemsChoiceType7, object> changeItem = new Dictionary<Request.ItemsChoiceType7, object>();
            exception.Location = null;
            changeItem.Add(Request.ItemsChoiceType7.Exceptions, exceptions);
            changeItem.Add(Request.ItemsChoiceType7.Recurrence, recurrence);
            changeItem.Add(Request.ItemsChoiceType7.Subject, subject);
            Request.SyncCollectionChangeApplicationData syncChangeData = new Request.SyncCollectionChangeApplicationData
            {
                ItemsElementName = changeItem.Keys.ToArray<Request.ItemsChoiceType7>(),
                Items = changeItem.Values.ToArray<object>()
            };

            Request.SyncCollectionChange syncChange = new Request.SyncCollectionChange
            {
                ApplicationData = syncChangeData,
                ServerId = calendar.ServerId
            };

            SyncRequest syncChangeRequest = new SyncRequest
            {
                RequestData = new Request.Sync { Collections = new Request.SyncCollection[1] }
            };

            syncChangeRequest.RequestData.Collections[0] = new Request.SyncCollection
            {
                Commands = new object[] { syncChange },
                SyncKey = syncResponse2.SyncKey,
                CollectionId = this.User1Information.CalendarCollectionId
            };

            // If an element in a recurring calendar item has been deleted in an Exception element, sends an empty tag
            // for this element to remove the inherited value from the server.
            string syncXmlRequest = syncChangeRequest.GetRequestDataSerializedXML();
            string changedSyncXmlRequest = syncXmlRequest.Insert(syncXmlRequest.IndexOf("</Exception>", StringComparison.CurrentCulture), "<Location />");
            SendStringResponse result = this.CALAdapter.SendStringRequest(changedSyncXmlRequest);

            #endregion

            #region Call Sync command to get the changed calendar.

            SyncStore initializeSyncResponse = this.InitializeSync(this.User1Information.CalendarCollectionId, null);
            syncRequest = TestSuiteHelper.CreateSyncRequest(this.User1Information.CalendarCollectionId, initializeSyncResponse.SyncKey, true);
            result = this.CALAdapter.SendStringRequest(syncRequest.GetRequestDataSerializedXML());

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result.ResponseDataXML);
            XmlNamespaceManager nameSpaceManager = new XmlNamespaceManager(doc.NameTable);
            nameSpaceManager.AddNamespace("e", "AirSync");
            XmlNodeList nodes = doc.SelectNodes("//e:Collections/e:Collection/e:Commands/e:Add/e:ApplicationData", nameSpaceManager);
            bool isEmptyLocationContained = false;
            foreach (XmlNode node in nodes)
            {
                bool isFound = false;
                XmlNodeList subNodes = node.ChildNodes;
                foreach (XmlNode subNode in subNodes)
                {
                    if (subNode.Name.Equals("Subject") && subNode.InnerText != null && subNode.InnerText.Equals(subject))
                    {
                        isFound = true;
                    }
                    if (isFound && subNode.Name.Equals("Exceptions"))
                    {
                        isEmptyLocationContained = subNode.InnerXml.Contains("<Location />");
                        break;
                    }
                }
                if (isEmptyLocationContained)
                {
                    break;
                }
            }

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R2242
            Site.CaptureRequirementIfIsTrue(
                isEmptyLocationContained,
                2242,
                @"[In Appendix B: Product Behavior]  If an element in a recurring calendar item has been deleted in an Exception element (section 2.2.2.19), the client sends an empty tag for this element to remove the inherited value from the implementation. (Exchange 2010 and above follow this behavior.)");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R539
            Site.CaptureRequirementIfIsTrue(
                isEmptyLocationContained,
                539,
                @"[In Sync Command Response] If one or more properties of an exception for recurring calendar item (that is, any child elements of the Exception element (section 2.2.2.19)) have been deleted, the server MUST transmit an empty element in the Sync command response to indicate that this property is not inherited from the recurrence.");

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

            // Verify MS-ASCAL requirement: MS-ASCAL_R543
            Site.CaptureRequirementIfIsTrue(
                isEmptyLocationContained,
                543,
                @"[In Indicating Deleted Elements in Exceptions] If an element of a recurring calendar item has been deleted in an Exception element (section 2.2.2.19), the server MUST send an empty tag for this element in the Sync command response ([MS-ASCMD] section 2.2.2.19).");

            #endregion
        }