public void MSOXCMAPIHTTP_S02_TC06_ResortRestriction() { this.CheckMapiHttpIsSupported(); #region Call Bind request type to established a session context with the address book server. this.Bind(); #endregion #region Call DNToMId to get a set of Minimal Entry IDs. These IDs will be used as the parameter of ResortRestriction. StringArray_r names = new StringArray_r { CValues = 2, LppzA = new string[] { this.AdminUserDN, Common.GetConfigurationPropertyValue("GeneralUserEssdn", this.Site) } }; DNToMinIdRequestBody requestBodyOfDNToMId = this.BuildDNToMinIdRequestBody(true, names); DnToMinIdResponseBody responseBodyOfDNToMinId = this.Adapter.DnToMinId(requestBodyOfDNToMId); Site.Assert.AreEqual<uint>(0, responseBodyOfDNToMinId.ErrorCode, "DnToMinId should succeed and 0 is expected to be returned. The returned value is {0}.", responseBodyOfDNToMinId.ErrorCode); #endregion #region Call ResortRestriction to sort the objects in a restricted address book container. STAT stat = new STAT(); stat.InitiateStat(); ResortRestrictionRequestBody resortRestrictionRequestBody = this.BuildResortRestriction(true, stat, true, responseBodyOfDNToMinId.MinimalIdCount.Value, responseBodyOfDNToMinId.MinimalIds); ResortRestrictionResponseBody resortRestrictionResponseBody = this.Adapter.ResortRestriction(resortRestrictionRequestBody); Site.Assert.AreEqual<uint>(0, resortRestrictionResponseBody.ErrorCode, "ResortRestriction should succeed and 0 is expected to be returned. The returned value is {0}.", resortRestrictionResponseBody.ErrorCode); #endregion #region Call QueryRows method to query rows which contain the specific properties. LargePropertyTagArray columns = new LargePropertyTagArray { PropertyTagCount = 1, PropertyTags = new PropertyTag[1] { new PropertyTag { PropertyType = (ushort)PropertyTypeValues.PtypString, PropertyId = (ushort)PropertyID.PidTagDisplayName } } }; QueryRowsRequestBody queryRowsRequestBody = this.BuildQueryRowsRequestBody( true, resortRestrictionResponseBody.State.Value, resortRestrictionResponseBody.MinimalIdCount.Value, resortRestrictionResponseBody.MinimalIds, resortRestrictionResponseBody.MinimalIdCount.Value, true, columns); QueryRowsResponseBody queryRowsResponseBody = this.Adapter.QueryRows(queryRowsRequestBody); Site.Assert.AreEqual<uint>(0, queryRowsResponseBody.ErrorCode, "QueryRows should succeed and 0 is expected to be returned. The returned value is {0}.", queryRowsResponseBody.ErrorCode); bool isCorrectOrder = true; AddressBookPropertyRow[] rowData = queryRowsResponseBody.RowData; for (int i = 0; i < queryRowsResponseBody.RowCount - 1; i++) { List<AddressBookPropertyValue> valueArray1 = new List<AddressBookPropertyValue>(rowData[i].ValueArray); List<AddressBookPropertyValue> valueArray2 = new List<AddressBookPropertyValue>(rowData[i + 1].ValueArray); if (string.Compare(valueArray1[0].Value.ToString(), valueArray2[0].Value.ToString()) > 0) { isCorrectOrder = false; break; } } // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R958"); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R958 this.Site.CaptureRequirementIfIsTrue( isCorrectOrder, 958, @"[In ResortRestriction Request Type] The ResortRestriction request type is used by the client to sort the objects in a restricted address book container."); #endregion #region Call ResortRestriction without state or minimal IDs. ResortRestrictionRequestBody resortRestrictionRequestBody2 = this.BuildResortRestriction(false, stat, false, responseBodyOfDNToMinId.MinimalIdCount.Value, responseBodyOfDNToMinId.MinimalIds); ResortRestrictionResponseBody resortRestrictionResponseBody2 = this.Adapter.ResortRestriction(resortRestrictionRequestBody2); Site.Assert.AreEqual<uint>(0, resortRestrictionResponseBody2.StatusCode, "ResortRestriction should succeed and 0 is expected to be returned. The returned value is {0}.", resortRestrictionResponseBody2.StatusCode); #endregion #region Call ResortRestriction with state and without minimal IDs. ResortRestrictionRequestBody resortRestrictionRequestBody3 = this.BuildResortRestriction(true, stat, false, responseBodyOfDNToMinId.MinimalIdCount.Value, responseBodyOfDNToMinId.MinimalIds); ResortRestrictionResponseBody resortRestrictionResponseBody3 = this.Adapter.ResortRestriction(resortRestrictionRequestBody3); Site.Assert.AreEqual<uint>(0, resortRestrictionResponseBody3.StatusCode, "ResortRestriction should succeed and 0 is expected to be returned. The returned value is {0}.", resortRestrictionResponseBody3.StatusCode); #endregion #region Call ResortRestriction without state but with minimal IDs. ResortRestrictionRequestBody resortRestrictionRequestBody4 = this.BuildResortRestriction(false, stat, true, responseBodyOfDNToMinId.MinimalIdCount.Value, responseBodyOfDNToMinId.MinimalIds); ResortRestrictionResponseBody resortRestrictionResponseBody4 = this.Adapter.ResortRestriction(resortRestrictionRequestBody4); Site.Assert.AreEqual<uint>(0, resortRestrictionResponseBody4.StatusCode, "ResortRestriction should succeed and 0 is expected to be returned. The returned value is {0}.", resortRestrictionResponseBody4.StatusCode); #endregion #region Call the Unbind request type to destroy the session context. this.Unbind(); #endregion }
/// <summary> /// Build the DNToMinId request body. /// </summary> /// <param name="hasNames">A Boolean value that specifies whether the Names field is present.</param> /// <param name="names">A StringsArray_r structure that contains the list of distinguished names (DNs) (1) to be mapped to Minimal Entry IDs.</param> /// <returns>The DNToMinId request body.</returns> private DNToMinIdRequestBody BuildDNToMinIdRequestBody(bool hasNames, StringArray_r names) { DNToMinIdRequestBody requestBodyOfDNToMId = new DNToMinIdRequestBody(); requestBodyOfDNToMId.Reserved = 0x0; requestBodyOfDNToMId.HasNames = hasNames; if (hasNames) { requestBodyOfDNToMId.Names = names; } byte[] auxIn = new byte[] { }; requestBodyOfDNToMId.AuxiliaryBuffer = auxIn; requestBodyOfDNToMId.AuxiliaryBufferSize = (uint)auxIn.Length; return requestBodyOfDNToMId; }