Exemple #1
0
        public void MSASCON_S03_TC07_ItemOperations_Status164()
        {
            this.CheckActiveSyncVersionIsNot140();

            #region User2 sends an email to User1
            this.SwitchUser(this.User2Information, true);

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);

            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call ItemOperations command with BodyPartPreference element and set the Type element to 3
            this.SwitchUser(this.User1Information, false);

            DataStructures.Sync syncItem           = this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);
            BodyPartPreference  bodyPartPreference = new BodyPartPreference()
            {
                Type = 3,
            };

            ItemOperationsRequest  itemOperationsRequest  = TestSuiteHelper.GetItemOperationsRequest(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, null);
            ItemOperationsResponse itemOperationsResponse = this.CONAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual("1", itemOperationsResponse.ResponseData.Status, "The ItemOperations operation should be success.");
            this.VerifyMessagePartStatus164(byte.Parse(itemOperationsResponse.ResponseData.Response.Fetch[0].Status));
            #endregion
        }
        public void MSASCON_S05_TC03_Search_Status164()
        {
            this.CheckActiveSyncVersionIsNot140();

            #region User2 sends an email to User1
            this.SwitchUser(this.User2Information, true);

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            if (Common.IsRequirementEnabled(220, this.Site))
            {
                #region Call Search command with BodyPartPreference element and set the Type element to 3
                this.SwitchUser(this.User1Information, false);

                DataStructures.Sync syncItem           = this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);
                BodyPartPreference  bodyPartPreference = new BodyPartPreference()
                {
                    Type = 3,
                };

                SearchRequest searchRequest            = TestSuiteHelper.GetSearchRequest(syncItem.Email.ConversationId, bodyPartPreference, null);
                DataStructures.SearchStore searchStore = this.CONAdapter.Search(searchRequest, false, 0);
                this.VerifyMessagePartStatus164(byte.Parse(searchStore.StoreStatus));
                #endregion
            }
        }
Exemple #3
0
        public void MSASCON_S03_TC08_ItemOperations_MessagePart()
        {
            this.CheckActiveSyncVersionIsNot140();

            #region User2 sends an email to User1
            this.SwitchUser(this.User2Information, true);

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string body                = Common.GenerateResourceName(Site, "Body");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, body);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call ItemOperations command without BodyPreference or BodyPartPreference element.
            this.SwitchUser(this.User1Information, false);

            // Get all of the email BodyPart data.
            BodyPartPreference bodyPartPreference = new BodyPartPreference()
            {
                Type = 2,
            };

            DataStructures.Sync syncItem        = this.SyncEmail(subject, User1Information.InboxCollectionId, true, bodyPartPreference, null);
            XmlElement          lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string allData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);

            DataStructures.Email email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, null, null);
            this.VerifyMessagePartWithoutPreference(email);

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

            // Verify MS-ASCON requirement: MS-ASCON_R340
            Site.CaptureRequirementIfIsNull(
                email.BodyPart,
                340,
                @"[In Sending a Message Part] The airsyncbase:BodyPart element is not present in the [ItemOperations command] response if the client did not request the message part, as specified in section 3.1.4.10.");
            #endregion

            #region Call ItemOperations command with only BodyPreference element.
            BodyPreference bodyPreference = new BodyPreference()
            {
                Type = 2,
            };

            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference);
            this.VerifyMessagePartWithBodyPreference(email);
            #endregion

            #region Call ItemOperations command with only BodyPartPreference element.
            bodyPartPreference = new BodyPartPreference()
            {
                Type                    = 2,
                TruncationSize          = 12,
                TruncationSizeSpecified = true,
            };

            email           = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, null);
            lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string truncatedData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
            this.VerifyMessagePartWithBodyPartPreference(email, truncatedData, allData, (int)bodyPartPreference.TruncationSize);

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

            // Verify MS-ASCON requirement: MS-ASCON_R236
            Site.CaptureRequirementIfIsNotNull(
                email.BodyPart,
                236,
                @"[In Sending a Message Part] If the client [Sync command request ([MS-ASCMD] section 2.2.1.21), Search command request ([MS-ASCMD] section 2.2.1.16) or] ItemOperations command request 9([MS-ASCMD] section 2.2.1.10) includes the airsyncbase:BodyPartPreference element (section 2.2.2.2), then the server uses the airsyncbase:BodyPart element (section 2.2.2.1) to encapsulate the message part in the response.");

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

            // A message part and its meta-data are encapsulated by BodyPart element in the ItemOperation response, so this requirement can be captured.
            Site.CaptureRequirement(
                39,
                @"[In BodyPart] The airsyncbase:BodyPart element ([MS-ASAIRS] section 2.2.2.10) encapsulates a message part and its meta-data in [a Sync command response ([MS-ASCMD] section 2.2.1.21),] an ItemOperations command response ([MS-ASCMD] section 2.2.1.10) [or a Search command response ([MS-ASCMD] section 2.2.1.16)].");
            #endregion

            #region Call ItemOperations command with both BodyPreference and BodyPartPreference elements.
            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, bodyPreference);
            this.VerifyMessagePartWithBothPreference(email);
            #endregion
        }
 public void Parse(XmlNode parentNode)
 {
     bool[] bodyTypeSet  = new bool[256];
     bool[] bodyTypeSet2 = new bool[256];
     foreach (object obj in parentNode.ChildNodes)
     {
         XmlNode xmlNode = (XmlNode)obj;
         string  namespaceURI;
         if ("Schema" == xmlNode.Name)
         {
             this.ParseSchemaTags(xmlNode);
         }
         else if ((namespaceURI = xmlNode.NamespaceURI) != null)
         {
             string localName3;
             if (!(namespaceURI == "AirSync:"))
             {
                 string localName2;
                 if (!(namespaceURI == "AirSyncBase:"))
                 {
                     if (namespaceURI == "RightsManagement:")
                     {
                         string localName;
                         if ((localName = xmlNode.LocalName) != null && localName == "RightsManagementSupport")
                         {
                             string innerText;
                             if ((innerText = xmlNode.InnerText) != null)
                             {
                                 if (innerText == "0")
                                 {
                                     this.rightsManagementSupport = false;
                                     continue;
                                 }
                                 if (innerText == "1")
                                 {
                                     this.rightsManagementSupport = true;
                                     continue;
                                 }
                             }
                             throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, false)
                                   {
                                       ErrorStringForProtocolLogger = "InvalidValueRightsManagementSupport"
                                   };
                         }
                     }
                 }
                 else if ((localName2 = xmlNode.LocalName) != null)
                 {
                     if (!(localName2 == "BodyPreference"))
                     {
                         if (localName2 == "BodyPartPreference")
                         {
                             BodyPartPreference bodyPartPreference = MailboxSchemaOptionsParser.ParsePreference <BodyPartPreference>(xmlNode, bodyTypeSet2, () => new BodyPartPreference());
                             if (bodyPartPreference != null)
                             {
                                 this.bodyPartPreferences.Add(bodyPartPreference);
                             }
                         }
                     }
                     else
                     {
                         BodyPreference bodyPreference = MailboxSchemaOptionsParser.ParsePreference <BodyPreference>(xmlNode, bodyTypeSet, () => new BodyPreference());
                         if (bodyPreference != null)
                         {
                             this.bodyPreferences.Add(bodyPreference);
                         }
                     }
                 }
             }
             else if ((localName3 = xmlNode.LocalName) != null)
             {
                 if (!(localName3 == "Truncation"))
                 {
                     if (!(localName3 == "RTFTruncation"))
                     {
                         if (!(localName3 == "MIMETruncation"))
                         {
                             if (localName3 == "MIMESupport")
                             {
                                 this.ParseMIMESupport(xmlNode.InnerText);
                             }
                         }
                         else
                         {
                             this.ParseMIMETruncation(xmlNode.InnerText);
                         }
                     }
                     else
                     {
                         this.ParseRtfTruncationSetting(xmlNode.InnerText);
                     }
                 }
                 else
                 {
                     this.ParseTextTruncationSetting(xmlNode.InnerText);
                 }
             }
         }
     }
 }
Exemple #5
0
        protected override void InternalCopyFrom(IProperty sourceProperty)
        {
            IBodyPartProperty bodyPartProperty = sourceProperty as IBodyPartProperty;

            if (bodyPartProperty == null)
            {
                throw new UnexpectedTypeException("IBodyPartProperty", sourceProperty);
            }
            List <BodyPartPreference> list = base.Options["BodyPartPreference"] as List <BodyPartPreference>;

            if (list == null || list.Count <= 0)
            {
                return;
            }
            BodyPartPreference bodyPartPreference = list[0];
            long       truncationSize             = bodyPartPreference.TruncationSize;
            bool       allOrNone  = bodyPartPreference.AllOrNone;
            long       num        = 0L;
            bool       flag       = true;
            StatusCode statusCode = StatusCode.Success;
            Stream     stream;

            if (truncationSize >= 0L && allOrNone)
            {
                stream = bodyPartProperty.GetData(bodyPartPreference.Type, -1L, out num, out this.attachments);
                if (stream == null)
                {
                    statusCode = StatusCode.BodyPart_ConversationTooLarge;
                }
                else if (stream.Length >= truncationSize && num > truncationSize)
                {
                    stream = null;
                    flag   = true;
                }
                else
                {
                    flag = false;
                    num  = stream.Length;
                }
            }
            else
            {
                stream = bodyPartProperty.GetData(bodyPartPreference.Type, truncationSize, out num, out this.attachments);
                if (stream == null)
                {
                    statusCode = StatusCode.BodyPart_ConversationTooLarge;
                }
                flag = (truncationSize >= 0L && (stream != null && stream.Length >= truncationSize && num > truncationSize));
            }
            base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace);
            base.XmlParentNode.AppendChild(base.XmlNode);
            XmlNode xmlNode     = base.XmlNode;
            string  elementName = "Status";
            int     num2        = (int)statusCode;

            base.AppendChildNode(xmlNode, elementName, num2.ToString(CultureInfo.InvariantCulture));
            base.AppendChildNode(base.XmlNode, "Type", ((int)bodyPartPreference.Type).ToString(CultureInfo.InvariantCulture));
            base.AppendChildNode(base.XmlNode, "EstimatedDataSize", num.ToString(CultureInfo.InvariantCulture));
            if (flag)
            {
                base.AppendChildNode(base.XmlNode, "Truncated", "1");
            }
            if (stream != null && stream.Length > 0L)
            {
                base.AppendChildNode(base.XmlNode, "Data", stream, -1L, XmlNodeType.Text);
            }
            int preview = bodyPartPreference.Preview;

            if (preview == 0)
            {
                return;
            }
            string text = ((IBodyPartProperty)sourceProperty).Preview;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            if (text.Length > preview)
            {
                text = text.Remove(preview);
            }
            text = text.TrimEnd(new char[0]);
            if (!string.IsNullOrEmpty(text))
            {
                base.AppendChildNode(base.XmlNode, "Preview", text);
            }
        }