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
}