Microsoft.Protocols.TestSuites.MS_ASAIRS.S02_BodyPreference.MSASAIRS_S02_TC12_NativeBodyTypeAndType_RTF C# (CSharp) Method

MSASAIRS_S02_TC12_NativeBodyTypeAndType_RTF() private method

private MSASAIRS_S02_TC12_NativeBodyTypeAndType_RTF ( ) : void
return void
        public void MSASAIRS_S02_TC12_NativeBodyTypeAndType_RTF()
        {
            #region Send a mail with an embedded OLE object
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.AttachOLE, subject, body);
            #endregion

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 3
                }
            };
            #endregion

            #region Verify Sync command
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);

            this.VerifyType(syncItem.Email, bodyPreference[0].Type);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R239
            Site.CaptureRequirementIfAreEqual<byte?>(
                3,
                syncItem.Email.NativeBodyType,
                239,
                @"[In NativeBodyType] [The value] 3 represents RTF.");
            #endregion

            #region Verify ItemOperations command
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference, null, null);

            this.VerifyType(itemOperationsItem.Email, bodyPreference[0].Type);
            #endregion

            #region Verify Search command
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, bodyPreference, null);

            this.VerifyType(searchItem.Email, bodyPreference[0].Type);

            try
            {
                Convert.FromBase64String(searchItem.Email.Body.Data);

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R179
                Site.CaptureRequirement(
                    179,
                    @"[In Data (Body)] If the value of the Type element is 3 (RTF), the value of the Data element is encoded using base64 encoding.");
            }
            catch (FormatException)
            {
                Site.Assert.Fail("The value of Data element should be encoded using base64 encoding.");
            }
            #endregion

            #region Verify requirements
            // According to above steps, requirement MS-ASAIRS_R306 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R306");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R306
            Site.CaptureRequirement(
                306,
                @"[In Type] [The value] 3 [of Type element] means RTF.");
            #endregion
        }
        #endregion