/// <summary>
        /// Builds a SmartForward request by using the specified source folder Id, source server Id and forward mime information.
        /// </summary>
        /// <param name="sourceFolderId">Specify the folder id of original mail item being forwarded</param>
        /// <param name="sourceServerId">Specify the server Id of original mail item being forwarded</param>
        /// <param name="forwardMime">The total forward mime</param>
        /// <returns>Returns the SmartForward request instance</returns>
        internal static SmartForwardRequest CreateSmartForwardRequest(string sourceFolderId, string sourceServerId, string forwardMime)
        {
            SmartForwardRequest request = new SmartForwardRequest
            {
                RequestData = new Request.SmartForward
                {
                    ClientId = System.Guid.NewGuid().ToString(),
                    Source   = new Request.Source {
                        FolderId = sourceFolderId, ItemId = sourceServerId
                    },
                    Mime = forwardMime
                }
            };

            request.SetCommandParameters(new Dictionary <CmdParameterName, object>
            {
                {
                    CmdParameterName.CollectionId, sourceFolderId
                },
                {
                    CmdParameterName.ItemId, sourceServerId
                }
            });
            return(request);
        }
Example #2
0
        public void MSASCMD_S17_TC02_SmartForward_Fail()
        {
            Site.Assume.AreNotEqual <string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The AccountID element is not supported 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>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The AccountID element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            #region Call SendMail command to send one plain text email messages to user2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            #region Call Sync command to sync user2 mailbox changes
            this.SwitchUser(this.User2Information);
            SyncResponse syncChangeResponse = this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject);
            string       originalServerId   = TestSuiteBase.FindServerId(syncChangeResponse, "Subject", emailSubject);
            #endregion

            #region Record user name, folder collectionId and item subject that are used in this case
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Call SmartForward command to forward messages without retrieving the full, original message from the server
            // Create invalid SmartForward request
            SmartForwardRequest smartForwardRequest = new SmartForwardRequest
            {
                RequestData = new Request.SmartForward
                {
                    ClientId = System.Guid.NewGuid().ToString(),
                    Source   = new Request.Source
                    {
                        FolderId = this.User2Information.InboxCollectionId,
                        ItemId   = originalServerId
                    },
                    Mime      = string.Empty,
                    AccountId = "InvalidValueAccountID"
                }
            };

            smartForwardRequest.SetCommandParameters(new Dictionary <CmdParameterName, object>
            {
                {
                    CmdParameterName.CollectionId, this.User2Information.InboxCollectionId
                },
                {
                    CmdParameterName.ItemId, "5:" + originalServerId
                }
            });

            SmartForwardResponse smartForwardResponse = this.CMDAdapter.SmartForward(smartForwardRequest);
            #endregion

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4408
            // If SmartForward operation failed, server will return Status element in response, then MS-ASCMD_4408 is verified.
            Site.CaptureRequirementIfIsNotNull(
                smartForwardResponse.ResponseData.Status,
                4408,
                @"[In Status(SmartForward and SmartReply)] If the SmartForward command request [or SmartReply command request] fails, the Status element contains a code that indicates the type of failure.");
        }
        /// <summary>
        /// Call SmartForward command to forward an email.
        /// </summary>
        /// <param name="itemServerId">The ServerId of the email to reply.</param>
        /// <param name="collectionId">The folder collectionId of the source email.</param>
        /// <param name="from">The mailbox address of sender.</param>
        /// <param name="forwardTo">The mailbox address of recipient.</param>
        /// <param name="subject">The subject of the email to reply.</param>
        protected void CallSmartForwardCommand(string itemServerId, string collectionId, string from, string forwardTo, string subject)
        {
            // Create SmartForward command request.
            Request.Source      source = new Request.Source();
            string              mime   = Common.CreatePlainTextMime(from, forwardTo, string.Empty, string.Empty, subject, "SmartForward content");
            SmartForwardRequest smartForwardRequest = Common.CreateSmartForwardRequest(null, System.Guid.NewGuid().ToString(), mime, source);

            // Set the command parameters.
            smartForwardRequest.SetCommandParameters(new Dictionary <CmdParameterName, object>());

            source.FolderId = collectionId;
            source.ItemId   = itemServerId;
            smartForwardRequest.CommandParameters.Add(CmdParameterName.CollectionId, collectionId);
            smartForwardRequest.CommandParameters.Add(CmdParameterName.ItemId, itemServerId);
            smartForwardRequest.RequestData.ReplaceMime = string.Empty;

            // Call SmartForward command.
            SmartForwardResponse smartForwardResponse = this.CONAdapter.SmartForward(smartForwardRequest);

            Site.Assert.AreEqual(string.Empty, smartForwardResponse.ResponseDataXML, "The SmartForward command should be executed successfully.");
        }
        /// <summary>
        /// Builds a SmartForward request by using the specified source folder Id, source server Id and forward mime information.
        /// </summary>
        /// <param name="sourceFolderId">Specify the folder id of original mail item being forwarded</param>
        /// <param name="sourceServerId">Specify the server Id of original mail item being forwarded</param>
        /// <param name="forwardMime">The total forward mime</param>
        /// <returns>Returns the SmartForward request instance</returns>
        internal static SmartForwardRequest CreateSmartForwardRequest(string sourceFolderId, string sourceServerId, string forwardMime)
        {
            SmartForwardRequest request = new SmartForwardRequest
            {
                RequestData = new Request.SmartForward
                {
                    ClientId = System.Guid.NewGuid().ToString(),
                    Source = new Request.Source { FolderId = sourceFolderId, ItemId = sourceServerId },
                    Mime = forwardMime
                }
            };

            request.SetCommandParameters(new Dictionary<CmdParameterName, object>
            {
                {
                    CmdParameterName.CollectionId, sourceFolderId
                },
                {
                    CmdParameterName.ItemId, sourceServerId
                }
            });
            return request;
        }
        /// <summary>
        /// Create a SmartForward request.
        /// </summary>
        /// <param name="folderId">The value of the FolderId element.</param>
        /// <param name="serverId">The value of the ServerId element.</param>
        /// <param name="from">The value of the From element.</param>
        /// <param name="to">The value of the To element.</param>
        /// <param name="cc">The value of the Cc element.</param>
        /// <param name="bcc">The value of the Bcc element.</param>
        /// <param name="subject">The value of the Subject element.</param>
        /// <param name="content">The value of the Content element.</param>
        /// <returns>the SmartForward request.</returns>
        protected SmartForwardRequest CreateSmartForwardRequest(string folderId, string serverId, string from, string to, string cc, string bcc, string subject, string content)
        {
            SmartForwardRequest request = new SmartForwardRequest
            {
                RequestData = new Request.SmartForward
                {
                    ClientId = TestSuiteBase.ClientId,
                    Source = new Request.Source { FolderId = folderId, ItemId = serverId }
                }
            };

            string mime = Common.CreatePlainTextMime(from, to, cc, bcc, subject, content);
            request.RequestData.Mime = mime;
            request.SetCommandParameters(new Dictionary<CmdParameterName, object>
            {
                {
                    CmdParameterName.CollectionId, folderId
                },
                {
                    CmdParameterName.ItemId, serverId
                }
            });

            return request;
        }
        public void MSASCMD_S17_TC02_SmartForward_Fail()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The AccountID element is not supported 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>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The AccountID element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            #region Call SendMail command to send one plain text email messages to user2.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null);
            #endregion

            #region Call Sync command to sync user2 mailbox changes
            this.SwitchUser(this.User2Information);
            SyncResponse syncChangeResponse = this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject);
            string originalServerId = TestSuiteBase.FindServerId(syncChangeResponse, "Subject", emailSubject);
            #endregion

            #region Record user name, folder collectionId and item subject that are used in this case
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject);
            #endregion

            #region Call SmartForward command to forward messages without retrieving the full, original message from the server
            // Create invalid SmartForward request
            SmartForwardRequest smartForwardRequest = new SmartForwardRequest
            {
                RequestData = new Request.SmartForward
                {
                    ClientId = System.Guid.NewGuid().ToString(),
                    Source = new Request.Source
                    {
                        FolderId = this.User2Information.InboxCollectionId,
                        ItemId = originalServerId
                    },
                    Mime = string.Empty,
                    AccountId = "InvalidValueAccountID"
                }
            };

            smartForwardRequest.SetCommandParameters(new Dictionary<CmdParameterName, object>
            {
                {
                    CmdParameterName.CollectionId, this.User2Information.InboxCollectionId
                },
                {
                    CmdParameterName.ItemId, "5:" + originalServerId
                }
            });

            SmartForwardResponse smartForwardResponse = this.CMDAdapter.SmartForward(smartForwardRequest);
            #endregion

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4408
            // If SmartForward operation failed, server will return Status element in response, then MS-ASCMD_4408 is verified.
            Site.CaptureRequirementIfIsNotNull(
                smartForwardResponse.ResponseData.Status,
                4408,
                @"[In Status(SmartForward and SmartReply)] If the SmartForward command request [or SmartReply command request] fails, the Status element contains a code that indicates the type of failure.");
        }