public void MSASCMD_S06_TC01_GetAttachment_Success()
        {
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command 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.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 14.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send a mail with normal attachment
            string subject = Common.GenerateResourceName(Site, "NormalAttachment_Subject");
            string body    = Common.GenerateResourceName(Site, "NormalAttachment_Body");
            this.SendEmailWithAttachment(subject, body);
            #endregion

            this.SwitchUser(this.User2Information);
            SyncResponse syncResponse = this.GetMailItem(this.User2Information.InboxCollectionId, subject);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject);

            Response.AttachmentsAttachment[] attachments = this.GetEmailAttachments(syncResponse, subject);
            Site.Assert.IsTrue(attachments != null && attachments.Length == 1, "The email should contain a single attachment.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5501
            // The attachment name in the sent email is "number1.jpg", so if there is only one attachment in the email and the attachment name is matched, this requirement can be covered.
            Site.CaptureRequirementIfAreEqual <string>(
                "number1.jpg",
                attachments[0].DisplayName,
                5501,
                @"[In GetAttachment] Instead, an Attachment element ([MS-ASAIRS] section 2.2.2.2) is included for each attachment.");

            #region Call GetAttachment command to fetch attachment
            string attachmentFileReference = attachments[0].FileReference;
            IDictionary <CmdParameterName, object> parameters = new Dictionary <CmdParameterName, object>();
            parameters.Add(CmdParameterName.AttachmentName, attachmentFileReference);

            GetAttachmentRequest request = new GetAttachmentRequest();
            request.SetCommandParameters(parameters);
            GetAttachmentResponse response = this.CMDAdapter.GetAttachment(request);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R157
            // The GetAttachment command response data xml only contains the size information of the attachment, if it is not null and includes the size information, this requirement can be covered.
            bool isVerifyR157 = !string.IsNullOrEmpty(response.ResponseDataXML) && Convert.ToInt32(response.ResponseDataXML) > 0;
            Site.CaptureRequirementIfIsTrue(
                isVerifyR157,
                157,
                @"[In GetAttachment] The GetAttachment command retrieves an email attachment from the server.<2>");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R160
            // In ExchangeCommonConfiguration.deployment.ptfconfig, HTTP/HTTPS has been specified, so GetAttachment command is issued within the HTTP POST command.
            Site.CaptureRequirement(
                160,
                @"[In GetAttachment] This command [GetAttachment] is issued within the HTTP POST command.");
            #endregion
        }
        public void MSASCMD_S06_TC01_GetAttachment_Success()
        {
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command 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.");
            Site.Assume.AreNotEqual<string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 14.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send a mail with normal attachment
            string subject = Common.GenerateResourceName(Site, "NormalAttachment_Subject");
            string body = Common.GenerateResourceName(Site, "NormalAttachment_Body");
            this.SendEmailWithAttachment(subject, body);
            #endregion

            this.SwitchUser(this.User2Information);
            SyncResponse syncResponse = this.GetMailItem(this.User2Information.InboxCollectionId, subject);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject);

            Response.AttachmentsAttachment[] attachments = this.GetEmailAttachments(syncResponse, subject);
            Site.Assert.IsTrue(attachments != null && attachments.Length == 1, "The email should contain a single attachment.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5501
            // The attachment name in the sent email is "number1.jpg", so if there is only one attachment in the email and the attachment name is matched, this requirement can be covered.
            Site.CaptureRequirementIfAreEqual<string>(
                "number1.jpg",
                attachments[0].DisplayName,
                5501,
                @"[In GetAttachment] Instead, an Attachment element ([MS-ASAIRS] section 2.2.2.2) is included for each attachment.");

            #region Call GetAttachment command to fetch attachment
            string attachmentFileReference = attachments[0].FileReference;
            IDictionary<CmdParameterName, object> parameters = new Dictionary<CmdParameterName, object>();
            parameters.Add(CmdParameterName.AttachmentName, attachmentFileReference);

            GetAttachmentRequest request = new GetAttachmentRequest();
            request.SetCommandParameters(parameters);
            GetAttachmentResponse response = this.CMDAdapter.GetAttachment(request);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R157
            // The GetAttachment command response data xml only contains the size information of the attachment, if it is not null and includes the size information, this requirement can be covered.
            bool isVerifyR157 = !string.IsNullOrEmpty(response.ResponseDataXML) && Convert.ToInt32(response.ResponseDataXML) > 0;
            Site.CaptureRequirementIfIsTrue(
                isVerifyR157,
                157,
                @"[In GetAttachment] The GetAttachment command retrieves an email attachment from the server.<2>");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R160
            // In ExchangeCommonConfiguration.deployment.ptfconfig, HTTP/HTTPS has been specified, so GetAttachment command is issued within the HTTP POST command.
            Site.CaptureRequirement(
                160,
                @"[In GetAttachment] This command [GetAttachment] is issued within the HTTP POST command.");
            #endregion
        }
Exemplo n.º 3
0
        public async Task <ApiResponse <GetAttachmentResponse> > QueryDocumentAsync(GetAttachmentRequest request)
        {
            var getAttachmentResponse = new ApiResponse <GetAttachmentResponse>(new GetAttachmentResponse());

            _httpClient.DefaultRequestHeaders.Clear();
            _httpClient.DefaultRequestHeaders.Add(ConstantString.AuthorizationKey, string.Format(ConstantString.AuthorizationValue, request.AccessToken));

            var attachmentRequest = await _httpClient.GetAsync(string.Format(ConstantString.AttachmentSuffix, request.LoanGuid)).ConfigureAwait(false);

            var content = await attachmentRequest.Content.ReadAsStringAsync().ConfigureAwait(false);

            getAttachmentResponse.StatusCode = attachmentRequest.StatusCode;
            getAttachmentResponse.Headers    = attachmentRequest.Headers.ToDictionary(x => x.Key, x => x.Value.ToString());

            if (!attachmentRequest.IsSuccessStatusCode)
            {
                getAttachmentResponse.Body.FailureResponse = JsonConvert.DeserializeObject <GenericFailuareResponse>(content);
            }
            else
            {
                getAttachmentResponse.Body.SuccessResponse = JsonConvert.DeserializeObject <List <Attachment> >(content);
            }

            return(getAttachmentResponse);
        }
Exemplo n.º 4
0
        public void Flow_tests()
        {
            var putDocResponse = Client.Documents.PostAsync(ClientTestData.Artists.Artist1Json).Result;

            var putRequest = new PutAttachmentRequest(
                putDocResponse.Id,
                putDocResponse.Rev,
                ClientTestData.Attachments.One.Name,
                ClientTestData.Attachments.One.ContentType,
                ClientTestData.Attachments.One.Bytes);
            var putAttachmentResponse = SUT.PutAsync(putRequest).Result;

            putAttachmentResponse.Should().BeSuccessfulPut(ClientTestData.Artists.Artist1Id);

            var getRequest = new GetAttachmentRequest(
                putAttachmentResponse.Id,
                putAttachmentResponse.Rev,
                ClientTestData.Attachments.One.Name);
            var getResponse = SUT.GetAsync(getRequest).Result;

            getResponse.Should().BeSuccessfulGet(ClientTestData.Artists.Artist1Id, ClientTestData.Attachments.One.Name);

            var deleteRequest = new DeleteAttachmentRequest(
                putAttachmentResponse.Id,
                putAttachmentResponse.Rev,
                ClientTestData.Attachments.One.Name);
            var deleteResponse = SUT.DeleteAsync(deleteRequest).Result;

            deleteResponse.Should().BeSuccessfulDelete(ClientTestData.Artists.Artist1Id);
        }
        public virtual HttpRequest Create(GetAttachmentRequest request)
        {
            var httpRequest = CreateFor<GetAttachmentRequest>(HttpMethod.Get, GenerateRequestUrl(request.DocId, request.DocRev, request.Name));

            httpRequest.SetIfMatch(request.DocRev);

            return httpRequest;
        }
        /// <summary>
        /// Retrieves an e-mail attachment from the server.
        /// </summary>
        /// <param name="request">A GetAttachmentRequest object that contains the request information.</param>
        /// <returns>GetAttachment command response</returns>
        public GetAttachmentResponse GetAttachment(GetAttachmentRequest request)
        {
            GetAttachmentResponse response = this.activeSyncClient.GetAttachment(request);

            this.VerifyTransportRequirements();
            this.VerifyWBXMLCapture(CommandName.GetAttachment, response);
            return(response);
        }
        public virtual HttpRequest Create(GetAttachmentRequest request)
        {
            var httpRequest = CreateFor <GetAttachmentRequest>(HttpMethod.Get, GenerateRequestUrl(request.DocId, request.DocRev, request.Name));

            httpRequest.SetIfMatch(request.DocRev);

            return(httpRequest);
        }
Exemplo n.º 8
0
        public virtual async Task <AttachmentResponse> GetAsync(GetAttachmentRequest request)
        {
            var httpRequest = CreateHttpRequest(request);

            using (var res = await SendAsync(httpRequest).ForAwait())
            {
                return(ProcessAttachmentResponse(res));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Provides a pre-signed URL for download of a completed attachment. This is an asynchronous
        /// API for use with active contacts.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the GetAttachment service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the GetAttachment service method, as returned by ConnectParticipant.</returns>
        /// <exception cref="Amazon.ConnectParticipant.Model.AccessDeniedException">
        /// You do not have sufficient access to perform this action.
        /// </exception>
        /// <exception cref="Amazon.ConnectParticipant.Model.InternalServerException">
        /// This exception occurs when there is an internal failure in the Amazon Connect service.
        /// </exception>
        /// <exception cref="Amazon.ConnectParticipant.Model.ThrottlingException">
        /// The request was denied due to request throttling.
        /// </exception>
        /// <exception cref="Amazon.ConnectParticipant.Model.ValidationException">
        /// The input fails to satisfy the constraints specified by Amazon Connect.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/connectparticipant-2018-09-07/GetAttachment">REST API Reference for GetAttachment Operation</seealso>
        public virtual Task <GetAttachmentResponse> GetAttachmentAsync(GetAttachmentRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetAttachmentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetAttachmentResponseUnmarshaller.Instance;

            return(InvokeAsync <GetAttachmentResponse>(request, options, cancellationToken));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetAttachment operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetAttachment operation on AmazonConnectParticipantClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetAttachment
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/connectparticipant-2018-09-07/GetAttachment">REST API Reference for GetAttachment Operation</seealso>
        public virtual IAsyncResult BeginGetAttachment(GetAttachmentRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetAttachmentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetAttachmentResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Exemplo n.º 11
0
        internal virtual GetAttachmentResponse GetAttachment(GetAttachmentRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetAttachmentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetAttachmentResponseUnmarshaller.Instance;

            return(Invoke <GetAttachmentResponse>(request, options));
        }
Exemplo n.º 12
0
        public virtual async Task <AttachmentResponse> GetAsync(GetAttachmentRequest request, CancellationToken cancellationToken = default)
        {
            var httpRequest = GetAttachmentHttpRequestFactory.Create(request);

            using (var res = await SendAsync(httpRequest, cancellationToken).ForAwait())
            {
                return(await AttachmentResponseFactory.CreateAsync(res).ForAwait());
            }
        }
Exemplo n.º 13
0
        public virtual HttpRequest Create(GetAttachmentRequest request)
        {
            Ensure.That(request, "request").IsNotNull();

            var httpRequest = new HttpRequest(HttpMethod.Get, GenerateRelativeUrl(request))
                              .SetRequestTypeHeader(request.GetType())
                              .SetIfMatchHeader(request.DocRev);

            return(httpRequest);
        }
Exemplo n.º 14
0
        protected virtual string GenerateRelativeUrl(GetAttachmentRequest request)
        {
            var urlParams = new UrlParams();

            urlParams.AddIfNotNullOrWhiteSpace("rev", request.DocRev);

            return(string.Format("/{0}/{1}{2}",
                                 new UrlSegment(request.DocId),
                                 new UrlSegment(request.Name),
                                 new QueryString(urlParams)));
        }
Exemplo n.º 15
0
        public virtual async Task <AttachmentResponse> GetAsync(GetAttachmentRequest request)
        {
            Ensure.That(request, "request").IsNotNull();

            using (var httpRequest = CreateHttpRequest(request))
            {
                using (var res = await SendAsync(httpRequest).ForAwait())
                {
                    return(ProcessAttachmentResponse(res));
                }
            }
        }
Exemplo n.º 16
0
        public void When_GET_of_an_existing_attachment_Using_id_The_attachment_is_returned_correctly()
        {
            var putDocResponse = Client.Documents.PostAsync(ClientTestData.Artists.Artist1Json).Result;

            var putRequest = new PutAttachmentRequest(
                putDocResponse.Id,
                putDocResponse.Rev,
                ClientTestData.Attachments.One.Name,
                ClientTestData.Attachments.One.ContentType,
                ClientTestData.Attachments.One.Bytes);
            var putAttachmentResponse = SUT.PutAsync(putRequest).Result;

            var getRequest = new GetAttachmentRequest(
                putAttachmentResponse.Id,
                ClientTestData.Attachments.One.Name);
            var getAttachmentResponse = SUT.GetAsync(getRequest).Result;

            getAttachmentResponse.Should().BeSuccessfulGet(ClientTestData.Artists.Artist1Id, ClientTestData.Attachments.One.Name);
            getAttachmentResponse.Content.Should().Equal(ClientTestData.Attachments.One.Bytes);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Create GetAttachmentRequest instance, because there is XML body for the GetAttachment command, then the RequestData always will be null
 /// </summary>
 /// <returns>A GetAttachmentRequest instance</returns>
 public static GetAttachmentRequest CreateGetAttachmentRequest()
 {
     GetAttachmentRequest request = new GetAttachmentRequest { RequestData = null };
     return request;
 }
Exemplo n.º 18
0
 public static Task <AttachmentResponse> PerformAsync(this IMyCouchClient client, GetAttachmentRequest request)
 {
     return(client.Attachments.GetAsync(request));
 }
        public void MSASCMD_S06_TC02_GetAttachment_Status500()
        {
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command 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.");
            Site.Assume.AreNotEqual<string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 14.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual<string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            // Send a mail with normal attachment
            string subject = Common.GenerateResourceName(Site, "NormalAttachment_Subject");
            string body = Common.GenerateResourceName(Site, "NormalAttachment_Body");
            this.SendEmailWithAttachment(subject, body);

            this.SwitchUser(this.User2Information);
            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, subject, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject);

            Response.AttachmentsAttachment[] attachments = this.GetEmailAttachments(syncResponse, subject);
            Site.Assert.IsTrue(attachments != null && attachments.Length == 1, "The email should contain a single attachment.");

            GetAttachmentRequest getAttachmentRequest = new GetAttachmentRequest();

            getAttachmentRequest.SetCommandParameters(new Dictionary<CmdParameterName, object>
            {
                {
                    CmdParameterName.AttachmentName, attachments[0].FileReference
                }
            });

            GetAttachmentResponse getAttachmentResponse = this.CMDAdapter.GetAttachment(getAttachmentRequest);
            Site.Assert.AreEqual<string>("OK", getAttachmentResponse.StatusDescription, "The attachment should be retrieved successfully.");

            // Delete the email in the Inbox folder.
            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);

            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", subject);
            SyncRequest syncRequest = TestSuiteBase.CreateSyncDeleteRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, serverId);
            this.Sync(syncRequest);

            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", subject), "The email should be deleted.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject);

            syncResponse = this.SyncChanges(this.User2Information.DeletedItemsCollectionId);
            Site.Assert.IsNotNull(TestSuiteBase.FindServerId(syncResponse, "Subject", subject), "The deleted email should be in the DeletedItems folder.");
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.DeletedItemsCollectionId, subject);

            try
            {
                // Call GetAttachment command again to fetch the deleted attachment.
                this.CMDAdapter.GetAttachment(getAttachmentRequest);
                Site.Assert.Fail("If the GetAttachment command is used to retrieve an attachment that has been deleted on the server, a 500 status code should be returned in the HTTP POST response.");
            }
            catch (System.Net.WebException exception)
            {
                int statusCode = ((System.Net.HttpWebResponse)exception.Response).StatusCode.GetHashCode();

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

                // Verify MS-ASCMD requirement: MS-ASCMD_R166
                Site.CaptureRequirementIfAreEqual<int>(
                    500,
                    statusCode,
                    166,
                    @"[In GetAttachment] If the GetAttachment command is used to retrieve an attachment that has been deleted on the server, a 500 status code is returned in the HTTP POST response.");
            }
        }
Exemplo n.º 20
0
 protected virtual HttpRequest CreateHttpRequest(GetAttachmentRequest request)
 {
     return(GetAttachmentHttpRequestFactory.Create(request));
 }
        public void MSASCMD_S06_TC02_GetAttachment_Status500()
        {
            Site.Assume.AreNotEqual <string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command 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.");
            Site.Assume.AreNotEqual <string>("14.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 14.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");
            Site.Assume.AreNotEqual <string>("16.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The GetAttachment command is not supported when the MS-ASProtocolVersion header is set to 16.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            // Send a mail with normal attachment
            string subject = Common.GenerateResourceName(Site, "NormalAttachment_Subject");
            string body    = Common.GenerateResourceName(Site, "NormalAttachment_Body");

            this.SendEmailWithAttachment(subject, body);

            this.SwitchUser(this.User2Information);
            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, subject, null);

            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject);

            Response.AttachmentsAttachment[] attachments = this.GetEmailAttachments(syncResponse, subject);
            Site.Assert.IsTrue(attachments != null && attachments.Length == 1, "The email should contain a single attachment.");

            GetAttachmentRequest getAttachmentRequest = new GetAttachmentRequest();

            getAttachmentRequest.SetCommandParameters(new Dictionary <CmdParameterName, object>
            {
                {
                    CmdParameterName.AttachmentName, attachments[0].FileReference
                }
            });

            GetAttachmentResponse getAttachmentResponse = this.CMDAdapter.GetAttachment(getAttachmentRequest);

            Site.Assert.AreEqual <string>("OK", getAttachmentResponse.StatusDescription, "The attachment should be retrieved successfully.");

            // Delete the email in the Inbox folder.
            syncResponse = this.SyncChanges(this.User2Information.InboxCollectionId);

            string      serverId    = TestSuiteBase.FindServerId(syncResponse, "Subject", subject);
            SyncRequest syncRequest = TestSuiteBase.CreateSyncDeleteRequest(this.LastSyncKey, this.User2Information.InboxCollectionId, serverId);

            this.Sync(syncRequest);

            syncRequest.RequestData.Collections[0].SyncKey = this.LastSyncKey;
            syncResponse = this.Sync(syncRequest);
            Site.Assert.IsNull(TestSuiteBase.FindServerId(syncResponse, "Subject", subject), "The email should be deleted.");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, subject);

            syncResponse = this.SyncChanges(this.User2Information.DeletedItemsCollectionId);
            Site.Assert.IsNotNull(TestSuiteBase.FindServerId(syncResponse, "Subject", subject), "The deleted email should be in the DeletedItems folder.");
            TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.DeletedItemsCollectionId, subject);

            try
            {
                // Call GetAttachment command again to fetch the deleted attachment.
                this.CMDAdapter.GetAttachment(getAttachmentRequest);
                Site.Assert.Fail("If the GetAttachment command is used to retrieve an attachment that has been deleted on the server, a 500 status code should be returned in the HTTP POST response.");
            }
            catch (System.Net.WebException exception)
            {
                int statusCode = ((System.Net.HttpWebResponse)exception.Response).StatusCode.GetHashCode();

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

                // Verify MS-ASCMD requirement: MS-ASCMD_R166
                Site.CaptureRequirementIfAreEqual <int>(
                    500,
                    statusCode,
                    166,
                    @"[In GetAttachment] If the GetAttachment command is used to retrieve an attachment that has been deleted on the server, a 500 status code is returned in the HTTP POST response.");
            }
        }