/// <summary> /// Deserialize the common field of restriction. /// </summary> /// <param name="restrictionData">The restriction data.</param> /// <returns>Return a new instance of a class extended from Restricts.</returns> public static Restriction Deserialize(byte[] restrictionData) { Restriction restricts = null; int index = 0; byte restrictType = restrictionData[index]; switch (restrictType) { case (byte)RestrictType.AndRestriction: AndRestriction andRestriction = new AndRestriction(); andRestriction.Deserialize(restrictionData); restricts = andRestriction; break; case (byte)RestrictType.NotRestriction: NotRestriction notRestriction = new NotRestriction(); notRestriction.Deserialize(restrictionData); restricts = notRestriction; break; case (byte)RestrictType.ContentRestriction: ContentRestriction contentRestriction = new ContentRestriction(); contentRestriction.Deserialize(restrictionData); restricts = contentRestriction; break; case (byte)RestrictType.PropertyRestriction: PropertyRestriction propertyRestriction = new PropertyRestriction(); propertyRestriction.Deserialize(restrictionData); restricts = propertyRestriction; break; case (byte)RestrictType.ExistRestriction: ExistRestriction existRestriction = new ExistRestriction(); existRestriction.Deserialize(restrictionData); restricts = existRestriction; break; default: throw new NotSupportedException("This restrict type '" + restrictType.ToString() + "'is not supported in this test suite."); } return(restricts); }
/// <summary> /// Deserialize the common field of restriction. /// </summary> /// <param name="restrictionData">The restriction data.</param> /// <returns>Return a new instance of a class extended from Restricts.</returns> public static Restriction Deserialize(byte[] restrictionData) { Restriction restricts = null; int index = 0; byte restrictType = restrictionData[index]; switch (restrictType) { case (byte)RestrictType.AndRestriction: AndRestriction andRestriction = new AndRestriction(); andRestriction.Deserialize(restrictionData); restricts = andRestriction; break; case (byte)RestrictType.NotRestriction: NotRestriction notRestriction = new NotRestriction(); notRestriction.Deserialize(restrictionData); restricts = notRestriction; break; case (byte)RestrictType.ContentRestriction: ContentRestriction contentRestriction = new ContentRestriction(); contentRestriction.Deserialize(restrictionData); restricts = contentRestriction; break; case (byte)RestrictType.PropertyRestriction: PropertyRestriction propertyRestriction = new PropertyRestriction(); propertyRestriction.Deserialize(restrictionData); restricts = propertyRestriction; break; case (byte)RestrictType.ExistRestriction: ExistRestriction existRestriction = new ExistRestriction(); existRestriction.Deserialize(restrictionData); restricts = existRestriction; break; default: throw new NotSupportedException("This restrict type '" + restrictType.ToString() + "'is not supported in this test suite."); } return restricts; }
public void MSOXCFOLD_S03_TC13_RestrictionDataValidation() { this.CheckWhetherSupportTransport(); this.Adapter.DoConnect(ConnectionType.PrivateMailboxServer); this.GenericFolderInitialization(); #region Step 1. The client calls RopCreateFolder to create [MSOXCFOLDSubfolder1] under the root folder. RopCreateFolderRequest createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Genericfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x01, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.Subfolder1), Comment = Encoding.ASCII.GetBytes(Constants.Subfolder1) }; RopCreateFolderResponse createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); ulong folderId = createFolderResponse.FolderId; uint folderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 2. The client creates a non-FAI message under [MSOXCFOLDSubfolder1]. ulong messageId1 = 0; uint messageHandle1 = 0; this.CreateSaveMessage(folderHandle, folderId, ref messageId1, ref messageHandle1); #endregion #region Step 3. The client calls RopCreateFolder to create a search folder [MSOXCFOLDSearchFolder1] under the root folder. createFolderRequest = new RopCreateFolderRequest { RopId = (byte)RopId.RopCreateFolder, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, OutputHandleIndex = Constants.CommonOutputHandleIndex, FolderType = (byte)FolderType.Searchfolder, UseUnicodeStrings = 0x0, OpenExisting = 0x01, Reserved = 0x0, DisplayName = Encoding.ASCII.GetBytes(Constants.SearchFolder), Comment = Encoding.ASCII.GetBytes(Constants.SearchFolder) }; createFolderResponse = this.Adapter.CreateFolder(createFolderRequest, this.RootFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, createFolderResponse.ReturnValue, "RopCreateFolder ROP operation performs successfully!"); uint searchFolderHandle = this.responseHandles[0][createFolderResponse.OutputHandleIndex]; #endregion #region Step 4. The client calls RopSetSearchCriteria to establish search criteria for [MSOXCFOLDSearchFolder1]. ulong[] folderIds = new ulong[] { folderId }; RopSetSearchCriteriaRequest setSearchCriteriaRequest = new RopSetSearchCriteriaRequest(); setSearchCriteriaRequest.RopId = (byte)RopId.RopSetSearchCriteria; setSearchCriteriaRequest.LogonId = Constants.CommonLogonId; setSearchCriteriaRequest.InputHandleIndex = Constants.CommonInputHandleIndex; ContentRestriction contentRestriction = new ContentRestriction { FuzzyLevelLow = FuzzyLevelLowValues.FL_PREFIX, FuzzyLevelHigh = FuzzyLevelHighValues.FL_IGNORECASE }; PropertyTag propertyTag = new PropertyTag { PropertyId = (ushort)MessagePropertyId.PidTagMessageClass, PropertyType = (ushort)PropertyType.PtypString }; contentRestriction.PropertyTag = propertyTag; TaggedPropertyValue taggedProperty = new TaggedPropertyValue { PropertyTag = propertyTag, Value = Encoding.Unicode.GetBytes("IPM.Task" + Constants.StringNullTerminated) }; contentRestriction.TaggedValue = taggedProperty; NotRestriction notRestriction = new NotRestriction { Restricts = contentRestriction }; setSearchCriteriaRequest.RestrictionDataSize = (ushort)notRestriction.Size(); byte[] restrictionData = notRestriction.Serialize(); setSearchCriteriaRequest.RestrictionData = restrictionData; setSearchCriteriaRequest.FolderIdCount = (ushort)folderIds.Length; setSearchCriteriaRequest.FolderIds = folderIds; setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.RestartSearch; RopSetSearchCriteriaResponse setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSetSearchCriteria ROP operation performs successfully!"); #endregion #region Step 5. The client calls RopGetSearchCriteria with the UseUnicode field set to 0x01 to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. RopGetSearchCriteriaRequest getSearchCriteriaRequest = new RopGetSearchCriteriaRequest { RopId = (byte)RopId.RopGetSearchCriteria, LogonId = Constants.CommonLogonId, InputHandleIndex = Constants.CommonInputHandleIndex, UseUnicode = 0x01, IncludeRestriction = 0x01, IncludeFolders = 0x01 }; RopGetSearchCriteriaResponse getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); Restriction restrictTemp = RestrictsFactory.Deserialize(getSearchCriteriaResponse.RestrictionData); NotRestriction notRestrictionTemp = (NotRestriction)restrictTemp; ContentRestriction contentRestrictionTemp = (ContentRestriction)notRestrictionTemp.Restricts; contentRestrictionTemp = (ContentRestriction)notRestrictionTemp.Restricts; string str = Encoding.Unicode.GetString(contentRestrictionTemp.TaggedValue.Value); #region Verify the requirements: MS-OXCFOLD_R127, MS-OXCFOLD_R137. // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R127"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R127 Site.CaptureRequirementIfAreEqual<string>( "IPM.Task" + Constants.StringNullTerminated, str, 127, @"[In RopGetSearchCriteria ROP Request Buffer] UseUnicode (1 byte): A Boolean value that is nonzero (TRUE) if the value of the RestrictionData field of the ROP response is to be in Unicode format."); #endregion #endregion #region Step 6. The client calls RopGetSearchCriteria with the UseUnicode field set to 0x00 to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. getSearchCriteriaRequest.UseUnicode = 0x00; getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); restrictTemp = RestrictsFactory.Deserialize(getSearchCriteriaResponse.RestrictionData); notRestrictionTemp = (NotRestriction)restrictTemp; contentRestrictionTemp = (ContentRestriction)notRestrictionTemp.Restricts; str = Encoding.Unicode.GetString(contentRestrictionTemp.TaggedValue.Value); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R128"); // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R128 Site.CaptureRequirementIfAreNotEqual<string>( "IPM.Task" + Constants.StringNullTerminated, str, 128, @"[In RopGetSearchCriteria ROP Request Buffer] UseUnicode (1 byte): [A Boolean value that is] zero (FALSE) otherwise [if the value of the RestrictionData field of the ROP response is not to be in Unicode format]."); #endregion #region Step 7. The client calls RopSetSearchCriteria to restart searching criteria for [MSOXCFOLDSearchFolder1]. setSearchCriteriaRequest.SearchFlags = (uint)SetSearchFlags.RestartSearch; setSearchCriteriaRequest.RestrictionDataSize = 0; setSearchCriteriaRequest.RestrictionData = null; setSearchCriteriaResponse = this.Adapter.SetSearchCriteria(setSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, setSearchCriteriaResponse.ReturnValue, "RopSetSearchCriteria ROP operation performs successfully!"); #endregion #region Step 8. The client calls RopGetSearchCriteria with the UseUnicode field set to 0x00 to obtain the search criteria and the status of the search folder [MSOXCFOLDSearchFolder1]. getSearchCriteriaRequest.UseUnicode = 0x01; getSearchCriteriaResponse = this.Adapter.GetSearchCriteria(getSearchCriteriaRequest, searchFolderHandle, ref this.responseHandles); Site.Assert.AreEqual<uint>(Constants.SuccessCode, getSearchCriteriaResponse.ReturnValue, "RopGetSearchCriteria ROP operation performs successfully!"); restrictTemp = RestrictsFactory.Deserialize(getSearchCriteriaResponse.RestrictionData); notRestrictionTemp = (NotRestriction)restrictTemp; contentRestrictionTemp = (ContentRestriction)notRestrictionTemp.Restricts; str = Encoding.Unicode.GetString(contentRestrictionTemp.TaggedValue.Value); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCFOLD_R105"); // Get the portion information of RestrictionData field is this data is same as the data set by the previous RopSetSearchCriteria request, this requirement can be verified. // Verify MS-OXCFOLD requirement: MS-OXCFOLD_R105 Site.CaptureRequirementIfAreEqual<string>( "IPM.Task" + Constants.StringNullTerminated, str, 105, @"[In RopSetSearchCriteria ROP Request Buffer] RestrictionDataSize (2 bytes): If the value of the RestrictionDataSize field is zero, the search criteria that were used most recently for the search folder container are used again."); #endregion }